Created
September 5, 2017 08:08
-
-
Save marble/870864f5823ef320f9ee8abc539caea4 to your computer and use it in GitHub Desktop.
Bash: Create a symlink on a remote server when 'ln' is disabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a script I used when I wanted to create a symlink on a remote web | |
# server, but that web server had the 'ln' command disabled (using cPanel's | |
# Jailshell). | |
# It works by creating a symlink on the local computer, then using rsync to copy | |
# that symlink to the remote server. | |
# Example: | |
# ./remote-symlink.sh myhost ../remote/path remote/target | |
if [ $# != 3 ]; then | |
echo "Usage: $0 <host> <target> <linkname>" >&2 | |
exit 1 | |
fi | |
tmpfile=$(tempfile) | |
ln -sf $2 $tmpfile | |
rsync -l $tmpfile $1:$3 | |
rm $tmpfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment