Passing %1 from cmd file to ftp script

Passing %1 from cmd file to ftp script

Post by Tes » Wed, 20 Nov 2002 02:36:37



Hello.
I'm having a problem passing a value from a command script to an ftp
script.
I need to be able to generate the filename to ftp dynamically within
the dos command file (preferable option), or at least be able to pass
it at the command line when the command file is run (backup option).

The filename displays in the dos section, but reverts to %1 or the
variable in the ftp script.

Here are samples:

: filename is yyyymmdd.csv:
for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set
thisDate=%%c%%a%%b
echo %thisDate%
set fileName=%thisDate% & ".csv"
cd c:\ftp
ftp -s:upload.ftp ftpServer

and the FTP file (upload.ftp):
username
password
put %fileName%
dir
quit

If I hardcode the filename in the ftp script, all's well. If I
eliminate the file extension, I can copy a file to a known name, like
uploadFile.csv, then use that known name in the FTP script. But I need
to be able to ftp a file whose name will change every day (the
filename is the current date in the format yyyymmdd.csv).
Any help getting the filename string to concatenate %thisDate% &
".csv" and being able to pass that generated name to an FTP script
will be greatly appreciated.
Tia,
Tess

 
 
 

Passing %1 from cmd file to ftp script

Post by Charles D » Wed, 20 Nov 2002 10:22:57



> Hello.
> I'm having a problem passing a value from a command script to an ftp
> script.
> I need to be able to generate the filename to ftp dynamically within
> the dos command file (preferable option), or at least be able to pass
> it at the command line when the command file is run (backup option).

> The filename displays in the dos section, but reverts to %1 or the
> variable in the ftp script.

> Here are samples:
> DOS command file:

> : filename is yyyymmdd.csv:
> for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set thisDate=%%c%%a%%b

Yeesh -- what a hideous kludge for getting the date into a variable!
I suspect you are using the Brand X command shell, and therefore in
the wrong newsgroup....

Quote:> echo %thisDate%
> set fileName=%thisDate% & ".csv"
> cd c:\ftp
> ftp -s:upload.ftp ftpServer

> and the FTP file (upload.ftp):
> username
> password
> put %fileName%
> dir
> quit

I think you want to generate your UPLOAD.FTP script dynamically:

  echo username       >  upload.ftp
  echo password       >> upload.ftp
  echo put %filename% >> upload.ftp
  echo dir            >> upload.ftp
  echo quit           >> upload.ftp
  ftp -s:upload.ftp ftpServer

--


 
 
 

Passing %1 from cmd file to ftp script

Post by Tes » Thu, 21 Nov 2002 07:46:49


Your "yeesh" is echoed by my "sheesh". :>) This is all Greek to me.
Thanks for the recommendation. I'm going to give that a try.


> > Hello.
> > I'm having a problem passing a value from a command script to an ftp
> > script.
> > I need to be able to generate the filename to ftp dynamically within
> > the dos command file (preferable option), or at least be able to pass
> > it at the command line when the command file is run (backup option).

> > The filename displays in the dos section, but reverts to %1 or the
> > variable in the ftp script.

> > Here are samples:
> > DOS command file:

> > : filename is yyyymmdd.csv:
> > for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set thisDate=%%c%%a%%b

> Yeesh -- what a hideous kludge for getting the date into a variable!
> I suspect you are using the Brand X command shell, and therefore in
> the wrong newsgroup....

> > echo %thisDate%
> > set fileName=%thisDate% & ".csv"
> > cd c:\ftp
> > ftp -s:upload.ftp ftpServer

> > and the FTP file (upload.ftp):
> > username
> > password
> > put %fileName%
> > dir
> > quit

> I think you want to generate your UPLOAD.FTP script dynamically:

>   echo username       >  upload.ftp
>   echo password       >> upload.ftp
>   echo put %filename% >> upload.ftp
>   echo dir            >> upload.ftp
>   echo quit           >> upload.ftp
>   ftp -s:upload.ftp ftpServer