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
bye
EOF

below the error i m getting with the file name

[error]

CurrentCollectorMeterReadBackup2008$value.tar.gz: No such file or directory

[/error]

Try

mget CurrentCollectorMeterReadBackup2008${value}.tar.gz

i used the above suggested command ,but getting the error as


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
bye
EOF

error:

Bad directory components
can't find list of remote files, oops

Put set -x in your script and check if your path and file names are correct.

yes evrting is fine,
when i m giving value manually in the script like 1020 it is pulling the file

mget CurrentCollectorMeterReadBackup20081020tar.gz

the path is correct and also files are there, the only problem is that when i entered the value the FTP is not taking that value and reading the file as

mget CurrentCollectorMeterReadBackup2008${value}.tar.gz

instead of

value=1020

mget CurrentCollectorMeterReadBackup20081020.tar.gz

#!/bin/ksh


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
bye
EOF

Below the complete o/p i m getting now

root@isau02:/data/tmp/testfeld> VAR=cri; ftp -n isau02 << EOF
> user jupp something
> dir s${VAR}pt
> bye
> EOF
-rwx------   1 jupp     users           13 Aug 14 11:38 script

still not getting is there anyother way to pass value in the script to FTP

Can you change your script like following:

from

mget CurrentCollectorMeterReadBackup2008${value}.tar.gz

to

dir CurrentCollectorMeterReadBackup2008????.tar.gz

... and post the output here.

using dir i m able to get the file name but how to copy it using FTP

#!/bin/ksh
set -x

cd /ednadtu3/u01/pipe/naveed/class
echo "Enter the month/day"
read value

ftp -n ddcappip031.tu.com << "EOF"
user amit jason
prompt
cd /ednpdtu7/u01/pipe/Incoming/CurrentCollector/MeterReads/backupfiles
dir CurrentCollectorMeterReadBackup2008????.tar.gz
bye
EOF

output
---------------------------------

+ cd /ednadtu3/u01/pipe/naveed/class
+ echo Enter the month/day
Enter the month/day
+ read value
1020
+ ftp -n ddcappip031.tu.com
+ 0< /tmp/sh3616862.2
Interactive mode off.

-rw-r----- 1 pipe pipe 79895161 Nov 19 23:05 CurrentCollectorMeterReadBackup20081119.tar.gz
-rw-r----- 1 pipe pipe 70604904 Nov 20 23:04 CurrentCollectorMeterReadBackup20081120.tar.gz
-rw-r----- 1 pipe pipe 70907652 Nov 21 23:05 CurrentCollectorMeterReadBackup20081121.tar.gz
-rw-r----- 1 pipe pipe 72986381 Nov 22 23:05 CurrentCollectorMeterReadBackup20081122.tar.gz
-rw-r----- 1 pipe pipe 68609570 Nov 23 23:04 CurrentCollectorMeterReadBackup20081123.tar.gz
-rw-r----- 1 pipe pipe 69937900 Nov 24 23:05 CurrentCollectorMeterReadBackup20081124.tar.gz
-rw-r----- 1 pipe pipe 70518963 Nov 25 23:05 CurrentCollectorMeterReadBackup20081125.tar.gz
-rw-r----- 1 pipe pipe 69788932 Nov 26 23:05 CurrentCollectorMeterReadBackup20081126.tar.gz
-rw-r----- 1 pipe pipe 70712364 Nov 27 23:04 CurrentCollectorMeterReadBackup20081127.tar.gz
-rw-r----- 1 pipe pipe 69530103 Nov 28 23:04 CurrentCollectorMeterReadBackup20081128.tar.gz
-rw-r----- 1 pipe pipe 69359582 Nov 29 23:04 CurrentCollectorMeterReadBackup20081129.tar.gz
-rw-r----- 1 pipe pipe 70377462 Nov 30 23:04 CurrentCollectorMeterReadBackup20081130.tar.gz
-rw-r----- 1 pipe pipe 71530553 Dec 1 23:05 CurrentCollectorMeterReadBackup20081201.tar.gz
-rw-r----- 1 pipe pipe 71315927 Dec 2 23:05 CurrentCollectorMeterReadBackup20081202.tar.gz
-rw-r----- 1 pipe pipe 71014908 Dec 3 23:05 CurrentCollectorMeterReadBackup20081203.tar.gz
-rw-r----- 1 pipe pipe 70006001 Dec 4 23:05 CurrentCollectorMeterReadBackup20081204.tar.gz
-rw-r----- 1 pipe pipe 72596207 Dec 5 23:05 CurrentCollectorMeterReadBackup20081205.tar.gz
-rw-r----- 1 pipe pipe 71755813 Dec 6 23:05 CurrentCollectorMeterReadBackup20081206.tar.gz
-rw-r----- 1 pipe pipe 71804873 Dec 7 23:05 CurrentCollectorMeterReadBackup20081207.tar.gz
-rw-r----- 1 pipe pipe 70321940 Dec 8 23:06 CurrentCollectorMeterReadBackup20081208.tar.gz
-rw-r----- 1 pipe pipe 71836264 Dec 9 23:05 CurrentCollectorMeterReadBackup20081209.tar.gz
-rw-r----- 1 pipe pipe 70717052 Dec 10 23:06 CurrentCollectorMeterReadBackup20081210.tar.gz
-rw-r----- 1 pipe pipe 73818543 Dec 11 23:05 CurrentCollectorMeterReadBackup20081211.tar.gz
-rw-r----- 1 pipe pipe 72596215 Dec 12 23:05 CurrentCollectorMeterReadBackup20081212.tar.gz
-rw-r----- 1 pipe pipe 71104767 Dec 13 23:05 CurrentCollectorMeterReadBackup20081213.tar.gz
-rw-r----- 1 pipe pipe 70855212 Dec 14 23:05 CurrentCollectorMeterReadBackup20081214.tar.gz
-rw-r----- 1 pipe pipe 87294203 Dec 15 23:07 CurrentCollectorMeterReadBackup20081215.tar.gz

-----------------------------------------------------

I asked you to just use 4 question marks instead of ${value}.

Yes . I have made changes in the previous post i m able to do dir

There is no filename with a 1020 in it.

Just checked it - when you use -v on ftp you should get a message like

450 blabla: No such file or directory

What happens if you use get instead of mget?

yes there is file on ddcappip031.tu.com

path is : ednpdtu7/u01/pipe/Incoming/CurrentCollector/MeterReads/backupfiles

Filename: CurrentCollectorMeterReadBackup20081020.tar.gz

ls -ltr CurrentCollectorMeterReadBackup20081020.tar.gz

-rw-r----- 1 pipe pipe 144570660 Oct 20 23:08 CurrentCollectorMeterReadBackup20081020.tar.gz

--------------------------------------------------------------------------
the problem is that in FTP is not recognising the value of $value as 1020
when using FTP -v it is showing

550 CurrentCollectorMeterReadBackup2008${value}.tar.gz: No such file or directory

I tried with both mget and get option

There is nothing wrong with the script version in Post #3. Note that the single quotes have been removed to allow expansion of ${value} .
The error message in Post #3 suggests that you have hit an old Linux bug in the FTP daemon. Either apply fixes or try specifying a directory name (with ./) on the mget line.

mget ./CurrentCollectorMeterReadBackup2008${value}.tar.gz