Jump to content

Having trouble with creating symlinks using shell script


sKunKbad

Recommended Posts

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 post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.