Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting a variable to an ftp script 1

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
My problem this is this:

Within the bourne shell I am get the user to input the date of a backup to check. (This is my $REPLY variable.)

I need to, after getting the input, export this variable $REPLY) to another script that is ftp'ing onto another server then getting the backup required by using the $REPLY variable inputted in script 1.

Explained better
1. The user inputs date
2. Next script is called (ftp script)
3. Uses the user input to specify which backup to 'get'

The backup will always be in this format where n = parts that change !

adsm_backup_01nnnnnnnn.log

Anyone know how to export the inputted date to the second script ?
 
ENTER DATE> 25-01-01

# this goes into $REPLY ...

(ftp script) $REPLY

ftp script started with $REPLY as it's $1 variable?

or do you need to create an ftp script on the fly?
 
The ftpscript is always going to be present but here's what I have so far:

The 1st script is:

print -n"Input the date you wish to check";read

/home/operator/ftpscript

Where ftpscript is the script that needs the reply exported to it so that it can do the following:

ftp script:

ftp [hostname]
binary
cd /var/backup/logs
get adsm_backup_01THIS IS WHERE THE VARIABLE WOULD GO*.log

 
In theory, you could do it without a static ftp script, which would be easier. Just put everything in a shell script, along the lines of

print -n "Input the date you wish to check";read

ftp hostname << !
binary
cd /var/backup/logs
get adsm_backup_01${REPLY}*.log
!

Greg.
 
Thanks for all your help everyone - see the final result (that works ! below):

print -n &quot;Please enter the date of the backup you wish to check and press <ENTER> &quot;;read
AAA
ftp -nv << AAA
open $M9
user $AS $PWD
binary
prompt off
cd /var/backup/logs
mget adsm_backup_01$REPLY*.log
AAA
 
Help me, I need that they say me since I can make a batch file (script)of FTP to a server in the UNIX shell solaris to another one server with UNIX
as I can create it in emacs
THANK YOU
 
Try this Javier,

ftp -nv <<!
open second_host
user user-name password
binary
put /tmp/file.txt /tmp/file.txt
! Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top