Simple shell script to FTP file from your Desktop to FTP server
#!/bin/sh
HOST='ftp.mistonline.in'
USER=''
PASSWD=''
FILE='file.txt'
ftp -n $HOST << END
quote USER $USER
quote PASS $PASSWDcd databackup/DB/
put $FILE
quit
END
exit 0
The Tricks
Getting the password to the ftp server without having the ftp client program read the password from /dev/tty requires two tricks:
- Using the -n option on the ftp client program to prevent the ftp client from trying to log in immediately. That way, the ftp client does not ask for a user ID and password. No use of /dev/tty.
- Use the ftp client program command quote to send user ID and password to the ftp server.
- The file /dev/tty is a character file with major number 5 and minor number 0, usually of mode 0666 and owner.group root.tty.
- /dev/tty helps output displayed to the (terminal)
Related posts:
- Simple Pagination Using PHP Script
- Simple PHP Login Script
- Simple file upload script using php
- Loading swf file from another server using crossdomain.xml
- Find Absolute Path Of A File Or Directory Using PHP
- Simple PHP mail Script
- Creating a simple class file using PHP
