Home » Infrastructure » Unix » FTP a file through UNIX script.--URGENT
FTP a file through UNIX script.--URGENT [message #98466] Tue, 09 November 2004 04:10 Go to next message
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 #98467 is a reply to message #98466] Wed, 10 November 2004 05:00 Go to previous messageGo to next message
gopal krishna
Messages: 5
Registered: September 2004
Junior Member
Hi,

You can use the follwoing sample script commands

ftp -i -n << END_FTP
open <server name/IP address>
user user name password
mput *
bye
END_FTP
Re: FTP a file through UNIX script.--URGENT [message #98484 is a reply to message #98466] Tue, 23 November 2004 03:33 Go to previous messageGo to next message
satya das
Messages: 6
Registered: July 2004
Junior Member
but what is END_FTP.
its not working guide me more
Re: FTP a file through UNIX script.--URGENT [message #98494 is a reply to message #98467] Tue, 30 November 2004 13:33 Go to previous messageGo to next message
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.--MacOSX [message #98548 is a reply to message #98494] Mon, 27 December 2004 12:59 Go to previous messageGo to next message
tg
Messages: 2
Registered: August 2002
Junior Member
It runs under OSX as well. Thank you
Re: FTP a file through UNIX script.--URGENT [message #98582 is a reply to message #98466] Mon, 17 January 2005 08:12 Go to previous messageGo to next message
ajay
Messages: 45
Registered: December 2000
Member
IN the ftp session i want to run a unix command
say wc -l filename
how do i do this?
Re: FTP a file through UNIX script.--URGENT [message #98608 is a reply to message #98494] Fri, 28 January 2005 16:06 Go to previous messageGo to next message
Anindya Banerjee
Messages: 5
Registered: December 2004
Junior Member
This works fine.

But I am not able to redirect the output to a log file. Any pointers?

Thanks in Advance,
- Anindya
Re: FTP a file through UNIX script.--URGENT [message #98625 is a reply to message #98494] Mon, 07 February 2005 15:35 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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
Re: Create a GDG through UNIX script.--URGENT [message #185554 is a reply to message #98466] Wed, 02 August 2006 05:35 Go to previous message
aravindkumars
Messages: 2
Registered: August 2006
Location: India
Junior Member
Hi,

I have a requirement to create a GDG of record Length 1460 in Mainframes thru Unix .

Plz help me in this with the script.


thanks,

Aravind

Previous Topic: Shell script
Next Topic: Batch file....
Goto Forum:
  


Current Time: Thu Mar 28 15:30:05 CDT 2024