passing parameter to ftp script from output of another ftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing parameter to ftp script from output of another ftp
# 1  
Old 03-11-2009
passing parameter to ftp script from output of another ftp

Hi,

I have a ftp script which first gets all the file names and echo's the latest file.

I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is
> Rename Temp File calloc:ICMP port unreachable

here is my script

ftp -nvi $SERVER > ${FILE_DIR}/NavigationftpLog << EOD
user $USER $PWD
cd $PATH
ls its_out*
bye
EOD

#Obtain the latest filename inside the variable filename using sort command
filename=`awk '{if($NF ~ "its_out") {print $NF}}' ${FILE_DIR}/NavigationftpLog | sort -r | sed -ne '1p'`
echo "filename is $filename"

Latest_File=$filename
export Latest_File
ftp -nvi $SERVER > ${FILE_DIR}/Navigationftp2Log << EOD
user $USER $PWD
cd $PATH
lcd $FILE_DIR
ascii
get $Latest_File
bye
EOD

Please advice!
# 2  
Old 03-11-2009
It's only a guess, but the error is reporting in rename...are you trying to retrieve the same file multiple times as you're testing? FTP will typically rename existing files of the same name by appending underscores - maybe it's this that's failing.
# 3  
Old 03-11-2009
I'm not renaming i need the same file name .and the files not even ftp'd once to local server Smilie
# 4  
Old 03-12-2009
1. Add an "echo Latest_File=$Latest_File" after "Latest_File=$filename". What value do you get? is it what you expected?

2. If yes, try the second ftp manually with exactly same steps (replace variables with their values). Can you reproduce the error?
# 5  
Old 03-12-2009
Data

When i added echo statement,output gave correct file name and i have tested second ftp manually added the file name to get statement and the error message did not appear. But how to automate this script ??? Smilie

Please advice!
# 6  
Old 03-13-2009
Frankly that doesn't make any sense. If you have run the exact same commands and its working, then the same should work via script too unless there is some chance of one or more variables not getting initialized to correct values before the 2nd ftp. Try doing echo of each variable being used in 2nd FTP. If that also doesn't yield any clues, I'm out of ideas.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Passing output parameter(Oracle) to variable in ksh Script

Hello, I have researched and tried many way to pass OUT parameter to be stored in variable in KSH Script.Still not success, please help. Here is my Store Procedure. create procedure testout3(v_in varchar2,v_out OUT integer) as begin v_out := 1; end; Here is my testvout.ksh #!/bin/ksh... (1 Reply)
Discussion started by: palita2601
1 Replies

2. Shell Programming and Scripting

FTP parameter

friends How can I pass the FTP parameter to the machine the user and password ip=192.168.80.15 user=FidenFtp pass=Ftp01Fiden ftp -n ip user pass that does not work for me (4 Replies)
Discussion started by: tricampeon81
4 Replies

3. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

4. Shell Programming and Scripting

Ftp script to output a directory name

Is there any way to include a directory name before the filename in the ftp session? Here is the script. DIRECTORY=`cat directory.txt|sed '/^$/d'` ( exec 4>&1 ftp -n>&4 2>&4|& print -p open $host print -p user $user $password print -p binary for D1 in... (0 Replies)
Discussion started by: ranjanp
0 Replies

5. Shell Programming and Scripting

Automated FTP script using .netrc to multiple FTP servers

Hi all, I'm using the following script to automated ftp files to 1 ftp servers host=192.168.0.1 /usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp open $host bin cd ${directory} put $files quit ftp and the .netrc file contain machine 192.168.0.1 login abc... (4 Replies)
Discussion started by: varu0612
4 Replies

6. Shell Programming and Scripting

passing value through ftp

how to pass value through FTP.Below the script in k-shell echo "Enter the month/day" read value ftp -v -n ddcappip031.tu.com << "EOF" user amit jason prompt cd /ednpdtu7/u01/pipe/Incoming/CurrentCollector/MeterReads/backupfiles mget CurrentCollectorMeterReadBackup2008'$value'.tar.gz... (13 Replies)
Discussion started by: ali560045
13 Replies

7. Shell Programming and Scripting

ftp script not able to connect to ftp server.

I have the following ftp script to get files from a remote location. However, on running the script I find that I am not even able to connect to ftp server. I am able to connect to ftp server using other GUI ftp tools like WS_FTP using the same IP. IP used here is a dummy IP. What can go... (3 Replies)
Discussion started by: gram77
3 Replies

8. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

9. Shell Programming and Scripting

Random parameters passing in FTP script

Hi I have a question. In the FTP script if we are passing all the required value like Hostname, username, password, Action(put or get), Filename, & mode(ascii or binary) through parameters then we have to pass these in the exact orders in which they are taken like if we defined Username=$2... (2 Replies)
Discussion started by: sourabhshakya
2 Replies

10. UNIX for Dummies Questions & Answers

passing ip address as a variable to script for ftp

Still a Beginner here .. Does anyone no how to get the IP address of the machine thats logged in (bearing in mind there will be others logged in) while they are logged in to the Unix server and pass this as a variable to a shell script so as I can FTP files to that machine via a shell script, at... (2 Replies)
Discussion started by: Gerry405
2 Replies
Login or Register to Ask a Question

Featured Tech Videos