I am writing a script which will automatically capture a screenshot and trigger iSight to take a still photo when the script is run, then upload it to FTP. Everything is perfect other then one thing, my FTP requires a username and password to be entered when prompted (after both images are captured)
heres what I have:
echo “GOLDENEYE ACTIVATED….”
screencapture -x screen.jpg
imagesnap Mugshot.jpg
ftp <YourServerHere>
Terminal Responds:
Connected to <YourServerHere>
Now, Username must be entered when this appears:
220 Welcome to <ServerDomain>, FTP server standing by ...
Name (<ServerName>.<DomainName>.:<Name>): <Type UserName Here - Hit Enter>
And, Password will be entered upon successful entry of a valid Username:
331 Hello <UserName>, your FTP account password is required:
Password: <Type Your Password Here - Hit Enter>
After the proper credentials are entered, Terminal will respond:
230-Login successful, your current directory is /
230 0 Kbytes used (0%) - authorized: 7340032 Kb
Remote system type is UNIX.
Using binary mode to transfer files.
And, to upload the images:
ftp> put /Mugshot.jpeg
ftp> put /Screen.jpeg
I am attempting to Automate the username and password entry after the prompts are given, in order for the script to be successful
the text would be, "username" and "password" to be entered after the each prompt is given.
i am completely new to terminal and scripts, just playing around in my spare time, please excuse anything which is incorrect here, thanks for ANY help and education!
A general solution is the expect
command.
But for your task, it's an overkill.
The ftp
reads commands from a standard input.
So just do:
ftp -n < command.txt
The -n
prevents the automatic prompts for username/password. We provide these explicitly using the user
command below.
The commands.txt
file will look like:
open host
user user password
put /path
bye