Skip to content

Instantly share code, notes, and snippets.

@xsnpdngv
Last active November 8, 2017 14:01
Show Gist options
  • Save xsnpdngv/39612f752f17cfd1166710454e4b035c to your computer and use it in GitHub Desktop.
Save xsnpdngv/39612f752f17cfd1166710454e4b035c to your computer and use it in GitHub Desktop.
FTP bash script
#!/bin/bash
# ============================================================================
# @file ftpsh
# @brief Script to execute command line arguments as FTP command
# @author Tamas Dezso <[email protected]>
# @date November 8, 2017
# ============================================================================
if [ $# -lt 1 ]
then
echo -e "\n Usage: $0 <ftp-command> [argument(s)]\n"
exit 1
fi
HOST=hostname.com
USER=username
PASS=password
DIR=/home/$USER
echo "ftp://$USER@$HOST:$DIR$ $@"
ftp -in $HOST <<EOF
user ${USER} ${PASS}
cd ${DIR}
bin
$@
bye
EOF
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment