[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: FTP From SQR



[David Ward <wardd@uwwvax.uww.edu> asks how to do FTP from within
 SQR.  If that's not what he's asking, oops.]


I've created batch files for FTP processes under Windows, so I can help
a little.  You'll have to check the syntax for the version of FTP that
you are using, and you can expect differences if you're trying to FTP
under UNIX.  Under UNIX, you might consider other file transfer options,
such as rcp.

Create a script for the FTP session.  Here's an example:

  open mymachine.myhost.com
  user
  myusername
  mypassword
  ascii
  cd /export/data1/cam_load
  put MYFILE.DAT myfile.dat
  quit

The script contains commands you'd type in any interactive FTP session,
with the special note that your username and password for the session
follow the 'user' command (each on a separate line).

Next, set up your SQR program to call the FTP program with the pre-
defined script.  Under Windows, you can create a batch file like this:

  @echo off
  echo FTPing files...
  ftp.exe -n -s:myscript.ftp > ftp.log
  echo Done. Check email for confirmation of job runs.

Of course, you don't need a batch file.  You can just put the ftp.exe
command directly into your CALL statement in the SQR.

Next, call the batch file (or a shell script equivalent in UNIX), or
just call the ftp program directly.

  ! under Windows
  Let $command = getenv('COMSPEC') || '/c '
  Let $command = $command || 'ftp.exe -n -s:myscript.ftp > ftp.log'
  Call System Using $command #status

  ! under UNIX
  Let $command = 'ftp < myscript.ftp > ftp.log'
  Call System Using $command #status

You probably should use full path names to files, and you should
definitely check #status and do something on error.

Caveat emptor: I have not actually tried any of this from SQR, so the
Call System code might be dysfunctional.  Check the archives for recent
posts on calling external commands from different operating systems.

Hope this helps.

Adam Dray