Operating System - OpenVMS
1753508 Members
4981 Online
108795 Solutions
New Discussion юеВ

Re: FTP command file issue

 
SOLVED
Go to solution
The Brit
Honored Contributor

Re: FTP command file issue

As hinted by Hoff, remove the "$" symbols from the lines following "$ ftp ..."

Dave
Jon Pinkley
Honored Contributor

Re: FTP command file issue

Dave,

One method that I haven't seen mentioned yet in this thread, is the use of ftp host /input=vms_file_with_ftp_commands The input file can have the remote username and password as the first two lines of the input file, followed by ftp commands to execute (including quit), alternatively, the username and password can be passed on the DCL FTP command line with /username and /password. In this case the /input file should not have the username and password. In other words, if the username and password are not specified using the command line /username and /password, then FTP will be expecting the username and password as the first two lines of input.

The integration of FTP in DCL commands is nowhere as seemless as the integration of DECnet into DCL. For example there is no $ RENAME/FTP DCL command. Also, some things just won't work when initiating a tcp session for each command, for example something like "quote site umask" commands, which only remain in effect only for the duration of the ftp session.

Example code to copy from 'vms_name' to 'unix_name' while making the 'unix_name' appear to be 'atomically' created. This transfers to a temporary file nmae 'xfr_name' on the remote side, then uses ftp rename to rename the file on the remote side. Note: There is no VMS command RENAME/FTP

$ pid = f$getjpi("","PID")
$ temp = "sys$scratch:ftpinput.''pid';"
$ create 'temp'
$ temp = f$search(temp)
$ close/nolog ftpcmd
$ open/append ftpcmd 'temp'
$ write ftpcmd "''ftp_user'"
$ write ftpcmd "''ftp_usrp'"
$ write ftpcmd "ascii"
$ write ftpcmd "quote site umask 111" ! change default protection for created files to -rw-rw-rw-
$ write ftpcmd "put ''vms_name' ''xfr_name'"
$ write ftpcmd "rename ''xfr_name' ''unix_name'"
$ write ftpcmd "quit"
$ close/nolog ftpcmd
$ if .not. debug
$ then
$ define/user sys$output nla0:
$ else
$ type* 'temp'
$ endif
$ set noon ! so we can manually process ftp status
$ ftp 'ftp_srv' /input='temp'
$ ftp_copy_code := '$status'/'$severity'
$ ftp_copy_status = f$element(0,"/",ftp_copy_code)
$ ftp_copy_severity = f$element(1,"/",ftp_copy_code)
$ last_status = ftp_copy_status
$ if ftp_copy_severity .eq. 1
$ then
$ ! put code here to be executed if file was successfully copied
$ 'nodeb' delete* 'temp'
$ else
$ ! put code here to be executed if file copy failed
$ endif

The biggest disadvantage of this method is that you have very limited error handling, about all you know it that the whole sequence succeeded, or that some part of it failed, but which part is not easy to determine.

Jon
it depends

Re: FTP command file issue

Thanks to one and all for your incisive comments and help (I'm on VMS8.3-1 by the way).

The copy/ftp command worked nicely, but didn't put the file onto the UNIX box in uppercase, which the FTP command minus the $s did, so I'm going with that for the time being.
Thanks again everyone.
dave.

Re: FTP command file issue

Actually have placed the uppercase filename in "", now the copy/ftp command works like a dream :o)
Hoff
Honored Contributor

Re: FTP command file issue

Quoting the target file specification is likely the most appropriate approach here.

I'll presume you're on OpenVMS I64 V8.2-1 or (more likely) OpenVMS I64 V8.3-1H1 here (AFAIK, there's no V8.3-1), and these versions also mean you can also alter your DCL-level command parsing settings as required. Specifically, this is the SET PROCESS /PARSE=EXTENDED command. This mechanism preserves file case (case-preserving, case-blind) and how application-level switches (foreign commands) and related are processed.

The extended parsing mechanism is often associated with making full use of ODS-5 disk structures, but is a separate process-level selection knob.