1834155 Members
2298 Online
110064 Solutions
New Discussion

Script for ftp

 
SOLVED
Go to solution
Juerg DENNEBERG
Advisor

Script for ftp

HI you all

I have a script to ftp a file from UX to NT. So far it works. It runs every day by CRON. The new job I got is: The name of the file to transfer includes the actual date in the form of "nameYYMMDD.dat". Where do I have what to include in my script only to transfer the actual file as the old ones have to remain on the source?

ftp <log.log 2>errors.err
open $GESTSYSTEM
user john passwd
put nameYYMMDD.dat
close
bye
EOF

Many thanks for your help
Regards
Juerg
The personal liberty goes so far as it does not affect the liberty of others
4 REPLIES 4
David_246
Trusted Contributor
Solution

Re: Script for ftp

file = `date "+%y%m%d"`

ftp
..
..
..
put name${file}.dat

Regs David
@yourservice
Alan Turner
Regular Advisor

Re: Script for ftp

Just to expand on David's reply - if you only want the name to include YYMMDD on the UX source, then change David's "put" line to read:

put name${file}.dat name.dat
Juerg DENNEBERG
Advisor

Re: Script for ftp

Hi David
Hi Alan

it works. Many thanks.

PS: there are no blanks on both sides of the "equal sign"

Regards
Juerg
The personal liberty goes so far as it does not affect the liberty of others
Steven E. Protter
Exalted Contributor

Re: Script for ftp

I recommend one change.

change
file = `date "+%y%m%d"`

to:

file=$(date "+%y%m%d")

# backticks are being deprecated as I leanred this week.

ftp
..
..
..
put name${file}.dat



One other thing.

Give David 10 points for a great script.

regards,

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com