FTP a file through UNIX script.--URGENT [message #98466] |
Tue, 09 November 2004 04:10 |
satya das
Messages: 6 Registered: July 2004
|
Junior Member |
|
|
Hi All,
Can anyone please help me to send a file i.e. through FTP from my unix directory say /satya/out to server.
how can i implement the same in my unix script.
Thanks & Regards
Satya
|
|
|
|
|
Re: FTP a file through UNIX script.--URGENT [message #98494 is a reply to message #98467] |
Tue, 30 November 2004 13:33 |
Sandy Hart
Messages: 1 Registered: November 2004
|
Junior Member |
|
|
The sample script for ftp was very helpful to me.
I was having trouble running a script with an ftp in it from unix to mainframe host. It kept using the wrong user name, so this script excerpt shows what I did:
#**********************************************************
# Below is the ftp script that goes into Prod.
# (1) Do not use the -n option so that it will use the .netrc file
# (2) Do not use a user statement because login is automatic
#**********************************************************
ftp -iv << EOF
open hostname
quote site UNIT=WORK RECFM=FB LRECL=80 BLKSIZE=18960
ascii
put unixfilename MVS.FILE.NAME
close
bye
EOF
#**********************************************************
# Below is the test version of the same ftp.
# To test from xterm or telnet unix session:
# (1) Include the ftp option -n so it will NOT use the .netrc file
# (2) Add a user line right after the open statement, like this:
# user tsoid password
# (3) run the script from xterm or telnet unix session:
# ./edw_ftp.scr boxname dev
#**********************************************************
ftp -inv << EOF
open hostname
user mytsoid mytsopassword
quote site UNIT=WORK RECFM=FB LRECL=80 BLKSIZE=18960
ascii
put unixfilename MVS.FILE.NAME
close
bye
EOF
|
|
|
|
|
|
Re: FTP a file through UNIX script.--URGENT [message #98625 is a reply to message #98494] |
Mon, 07 February 2005 15:35 |
kim
Messages: 116 Registered: December 2001
|
Senior Member |
|
|
hi,
I used the same syntax but got an error at '<<' The code sample is as below:
36 for arg in "$@"
37 do
38 FILE=$arg
39
40 ftp -niv<<EOF
41 open $HOST
42 user $USER $PASSWD
43 cd $HOSTDIR
44 binary
45 get $FILE$DT$EXT
46 close
47 bye
48 EOF
49 done
Any advise?
Thanks,
Kim
|
|
|
Re: FTP a file through UNIX script.--URGENT [message #128024 is a reply to message #98625] |
Thu, 14 July 2005 12:48 |
sumakads
Messages: 2 Registered: July 2005 Location: Detroit USA
|
Junior Member |
|
|
I am looking for help in the same area. If someone has an answer pl reply.
I am ftping to a mainframe, from unix, (HP-UX)
The FTP is working fine, but how do i capture the success/failure of the FTP. if its a success, it comes out without any message.
I need to do furthur process depending on the status.
Thanks, pl help urgent.
|
|
|
Re: FTP a file through UNIX script.--URGENT [message #148870 is a reply to message #128024] |
Mon, 28 November 2005 16:09 |
mchittib
Messages: 87 Registered: September 2005
|
Member |
|
|
u could add the following in .netrc file
machine <server name> login <service Account> password <pwd>
result=`ftp -v <<**
open $MACHINE
put file.txt $DESTINATION/filename.dat
bye
**`
value=`echo "$result" |grep "226 Transfer complete" |wc -l`
if [ $value = 1 ]
then
echo "\nFTP Success"
else
echo "\nFTP Failure"
fi
|
|
|
|