Computing.Net > Forums > Unix > ftp shell script skip login

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ftp shell script skip login

Reply to Message Icon

Name: channella
Date: April 22, 2003 at 00:16:51 Pacific
OS: win 2K pro
CPU/Ram: pentium 3
Comment:

How do i skip the user login when i try to do a ftp in shell script? if i do the ftp at the command prompt, i will hit on the carriage return when the login is prompted.
a normal ftp script would looks like this:
#!/bin/ksh

HOST='12.34.56.67'
USER='userid'
PASSWD='password'
FILE='file.txt'

ftp -n $HOST END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0




Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: April 22, 2003 at 04:28:38 Pacific
Reply:

ftp -n -i $HOST !!
user $USER $PASSWD
hash
bin
put $FILE
close
quit
!!


0

Response Number 2
Name: Satalink
Date: April 22, 2003 at 09:58:09 Pacific
Reply:

Create a file .netrc in your users $HOME dir

write to that file:

machine remotehostname login userid password useridpassword

fill in the blanks for remotehostname, userid, and useridpassword.

save the file and ftp to remotehostname


0

Response Number 3
Name: Satalink
Date: April 22, 2003 at 09:59:47 Pacific
Reply:

create a .netrc file with the following info in the $HOME directory of the user the script will be ran by.

.netrc
::::::::::
machine remotehost login username password pass123

Then:
1. create your primary script that gathers and sets the variables. Have that script dynamically create the temporary ftp script through
set DATE=`date +%Y%m%d%H%M`
echo "ftp hostname 1>/dev/null 2>&1 EOF" > tmp_ftp.sh
echo "lcd /local/dir/of/files" >> tmp_ftp.sh
echo "cd /remote/dir/to/put/files" >> tmp_ftp.sh
echo "prompt off" >> tmp_ftp.sh
echo "mput *.${DATE}" >> tmp_ftp.sh
echo "quit" >> tmp_ftp.sh

# Change permissions of your temp script
chmod 744 tmp_ftp.sh
# Then run that script you just wrote.
tmp_ftp.sh

# you can rm the temp script or just leave it so long as the first echo is redirected with a single ">" for overwrite mode and all others are ">>" for append mode.



0

Response Number 4
Name: channella
Date: April 22, 2003 at 23:22:21 Pacific
Reply:

thanks Satalink! but theres no login for the particular hostname that i want to connect for the ftp transfer. I cant leave the username as '' or '\\c'. It will cause error when i execute the script


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: ftp shell script skip login

FTP Shell sample www.computing.net/answers/unix/ftp-shell-sample/2120.html

telnet & ftp through shell script?! www.computing.net/answers/unix/telnet-amp-ftp-through-shell-script/4850.html

ftp sql results in shell script www.computing.net/answers/unix/ftp-sql-results-in-shell-script/6338.html