sKunKbad Posted June 27, 2015 Share Posted June 27, 2015 I'm having trouble with creating symlinks using a shell script. They end up being broken (dangling) unless I use the full path, but I'd like to make this script semi-portable. I'm over-simplifying this: #!/bin/bash if [ ! -f ./lib/electro.php ]; then ln -s ./source/lib/electro.php ./lib/electro.php fi This script is called .install.sh, and is located at ./source/scripts/.install.sh So I go to my terminal, cd to where ./ would reference and run: skunkbad: /var/www/example/application$ ./source/scripts/.install.sh The script does end up creating the symlink in the proper location, but it's a broken link. If I list the directory, it will look something like this: lrwxrwxrwx 1 skunkbad www-data 51 Jun 26 17:40 electro.php -> ./source/lib/electro.php But it's colored red, which is broken / dangling and it doesn't work. My installer script will work as expected if I use an absolute path. What am I doing wrong? Should I somehow insert the absolute path as the script runs? Link to comment https://forums.phpfreaks.com/topic/297059-having-trouble-with-creating-symlinks-using-shell-script/ Share on other sites More sharing options...
sKunKbad Posted June 27, 2015 Author Share Posted June 27, 2015 Sorry, i figured it out already. The relative location is relative to the link, not where the script is running. Link to comment https://forums.phpfreaks.com/topic/297059-having-trouble-with-creating-symlinks-using-shell-script/#findComment-1515067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.