Computing.Net > Forums > Unix > Remote directory for FTP

Remote directory for FTP

Reply to Message Icon

Original Message
Name: Leslie
Date: September 3, 2002 at 01:18:15 Pacific
Subject: Remote directory for FTP
Comment:

I have written an automated FTP script for mput (ie. to put many files from a local to a remote host). However, I will only know the remote directory during run-time.

Example :

If condition A
remote_dir = A
elseif condition B
remote_dir = B
elseif condition C
remote_dir = C
else
remote_dir = D
endif

How do I do this ?? Can I pass in a variable from the shell script to the FTP script ??



Report Offensive Message For Removal


Response Number 1
Name: joe
Date: September 3, 2002 at 06:28:00 Pacific
Subject: Remote directory for FTP
Reply: (edit)

Why can't they be the same script?


Report Offensive Follow Up For Removal

Response Number 2
Name: Leslie
Date: September 3, 2002 at 18:44:51 Pacific
Subject: Remote directory for FTP
Reply: (edit)

Sorry, but they are actually in the same script. The script goes something like this:

# Check for condition.


If condition A
$1 = A
elseif condition B
$1 = B
elseif condition C
$1 = C
else
$1 = D
endif

# FTP Scripts

ftp -n -v -i servername > Logfile < user username password
lcd local_directory
cd $1
ascii
mput *
quit

EOF


It seems that $1 did not take the value of the If condition statement above. Can I pass in the value of $1 from the condition script to the FTP script ??


Report Offensive Follow Up For Removal

Response Number 3
Name: Xavier HECQUET
Date: September 4, 2002 at 07:15:15 Pacific
Subject: Remote directory for FTP
Reply: (edit)

Instead of redirecting the standard input (/tmp/tmp.ftp
echo "password">>/tmp/tmp.ftp
echo "lcd local_directory">>/tmp/tmp.ftp
echo "cd $1">/tmp/tmp.ftp
echo "...
and then, inside your script:
ftp -n -v -i servername > Logfile Hope this could help you...


Report Offensive Follow Up For Removal

Response Number 4
Name: Leigh
Date: September 4, 2002 at 16:12:09 Pacific
Subject: Remote directory for FTP
Reply: (edit)

I'm currently writing something similar to this. What I've done is written some code that obtains a list of directories from the remote server, gets a list of files from those directories then transfers them via ftp.

Once I have the list of directories and files, my code then creates an FTP command file that has the directory to change to and the files to get (our could use mget). This way I don't need to know the directories on the remote server till the code runs and it finds the directories it self.

eg ftp -iv host < ftp.cmd
{This runs the ftp.cmd file on the remote server.)

Please feel free to contact me if you wish to discuss this further.

Cheers.

Leigh


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Remote directory for FTP

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software