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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in script,when using stars in the name of file 2

Status
Not open for further replies.

Syky

IS-IT--Management
Mar 13, 2003
44
IE
Hi!
I've found script in this forum about using ftp script to transfer file from UX server to NT server.I have modify it to my needs,but have problems to transfer file when using stars in file.(AS******.ASN) Pls.note that I have to use it like that,because file to transfer is changing everyday and has different name.Can somebody help me?Pls.see script below.....

#!/bin/ksh

# ftp server/login info
FTP_HOST=edi
FTP_USER=3700
FTP_PASSWD=3700

# local directory
LOCAL_DIR=/IN/03700

# remote directory
REMOTE_DIR=/home/xfer/out/03380

# file
XMT_FILE=AS******.ASN

# command
COMMAND=put #put or get

ftp -n $FTP_HOST<<END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASSWD
$COMMAND $REMOTE_DIR/$XMT_FILE $LOCAL_DIR/$XMT_FILE
quit
END_SCRIPT
 
Have you tried surrounding the variable in single quotes?

XMT_FILE='AS******.ASN'

-jim
 
Jim, I've tried to us single quotes,but doesn't work.Have You any others recommendations !?
thx
 
Is the file actually 'AS', followed by 6 varying characters, then '.ASN' ?
If so, then AS??????.ASN is the more usual notation.
If the file is AS followed by any number of characters then AS*.ASN would do.
As for passing the filename into a variable - do :
for XMT_FILE in `ls AS*.ASN`
do
COMMAND=put #put or get
ftp -n $FTP_HOST<<END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASSWD
$COMMAND $REMOTE_DIR/$XMT_FILE $LOCAL_DIR/$XMT_FILE
quit
END_SCRIPT
done

NB There's no indents in the do->done - otherwise <<END_SCRIPT fails

HTH Dickie Bird (:)-)))
 
If your filename is something like:

AS01234.ASN or AS12.ASN

then AS*.ASN will work instead of all the extra *'s.

It seems that wildcard expansion only works using the put command and not get. At least on my system it does.

-jim
 
Hi!This is my current script(see below),but doesn't work.I'm getting this mess.
/IN/03700/AS*.ASN: The filename, directory name, or volume label syntax is incorrect

I tried to use specific file(AS000005.ASN)and it works!But when I put wildcard, it doesn't.Don't understand.I have tried both offered sulutions from You gents,but it failed.
---------------------------------------------------------

#!/bin/ksh

# ftp server/login info
FTP_HOST=edi
FTP_USER=3700
FTP_PASSWD=3700

# local directory
LOCAL_DIR=/home/xfer/out/03380

# remote directory
REMOTE_DIR=/IN/03700

# file
XMT_FILE='AS*.ASN'


# command
COMMAND=put #put or get

ftp -n $FTP_HOST<<END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASSWD
$COMMAND $LOCAL_DIR/$XMT_FILE $REMOTE_DIR/$XMT_FILE
quit
END_SCRIPT

 
for XMT_FILE in `ls AS*.ASN`
do
COMMAND=put #put or get
ftp -n $FTP_HOST<<END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASSWD
$COMMAND $REMOTE_DIR/$XMT_FILE $LOCAL_DIR/$XMT_FILE
quit
END_SCRIPT
done

Doesn't work ?????
Hmmm-m-m The 'ls AS*.ASN` should expand to all files matching, eg AS030303.ASN, and be subject to the put in the FTP Dickie Bird (:)-)))
 
Dickie.After I use it as You recommended,I'll get this message:
/home/xfer/out/03380/ls: No such file or directory

????
 
I think you have used 'ls AS*.ASN' and not `ls AS*.ASN`
The ` is backtick, not single quote '
- just cut and paste my code. Dickie Bird (:)-)))
 
I've just did, what You recommend, but got this errors!?
AS*.ASN not found
/home/xfer/out/03380/: not a plain file

...???....
 
If you run ls -l AS*.ASN in your required directory, do any files show at all ? Are they really UPPERCASE ? Dickie Bird (:)-)))
 
For multiple files you should be able to use mput AS*.ASN with no need for looping. You will have to use the ftp -i option to disable interactive prompting. So your script is...
[tt] :
COMMAND=mput #put or get
ftp -i -n $FTP_HOST<<END_SCRIPT
:[/tt]

Incidentally the syntax of the &quot;for&quot; loop is overkill. I wouldn't use...

[tt] for XMT_FILE in `ls AS*.ASN`[/tt]

when you can use the simpler...

[tt] for XMT_FILE in AS*.ASN[/tt]

----Ygor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top