Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

FTP command file issue

 
SOLVED
Go to solution

FTP command file issue

Hello, I have a niggle - I've written a .com file with an 'FTP server user pass' line in, but when it's run it immediately logs out.
What am I doing wrong?
14 REPLIES 14
Hoff
Honored Contributor
Solution

Re: FTP command file issue

OpenVMS V6.2 with its contemporary IP stacks introduced the COPY /FTP command, which is usually vastly easier to incorporate into a DCL command procedure.

http://labs.hoffmanlabs.com/node/136

As for what's wrong with your particular DCL code here, you'll want to post that code, how you're invoking the code ("immediately logs out" can be indicative of a user-mode coding error in some contexts, or of an inner-mode and thus more serious error in others), along with some information on which IP stack and version and ECO level is in use here, and the OpenVMS version.


Duncan Morris
Honored Contributor

Re: FTP command file issue

Dave,

please make a text file copy of the command procedure and post it as an attachment.

Without this information, we will be left guessing in the dark.

Duncan

Re: FTP command file issue

$ ftp serv /USERNAME="user" /PASSWORD="pass"
$ put test.ops "TEST.OPS"
$ ascii
$ quit

It gets as far as logging in then comes back with a '221 goodbye'.

Re: FTP command file issue

I meant to add, when i run each line manually it all works correctly.
Craig A
Valued Contributor

Re: FTP command file issue

Try:

$ COPY/FTP/ASCII/LOG TEST.OPS -
SERV"username password"::

Craig

Re: FTP command file issue

Should've added that the put test.ops "TEST.OPS" was because it's going onto a UNIX box, and I need it in uppercase.
Hoff
Honored Contributor

Re: FTP command file issue

The put and quit and such are ftp commands and are not $ DCL commands, and just as soon as the $ ftp command connects, the EOF that arises when an application (FTP) reads its data encounters a $, the connection gets torn down.

If this is V6.2 or later, use this:

$ COPY /FTP /ASCII test.ops -
server"user pass"::TEST.OPTS
$

If this is older or if you want to use the hard way, then use this:

$ ftp serv /USERNAME="user" /PASSWORD="pass"
ascii
put test.ops TEST.OPS
quit
$

And the next thing you'll usually encounter with "the hard way" is that you can't do DCL symbol substitution in the commands, which means you need to use a custom-created file for the transfer and @ it.

http://labs.hoffmanlabs.com/node/1339

An example of building a data file from DCL:

http://labs.hoffmanlabs.com/node/163

If you're just getting going with DCL and DCL procedures, have a look at the User's Guide in the OpenVMS manual set, too.
Hoff
Honored Contributor

Re: FTP command file issue

> I meant to add, when i run each line manually it all works correctly.

I would doubt you entered ftp> $ put

In a DCL procedure, the $ is a flag that indicates "this is a DCL command". Bash doesn't have something similar here, if you're coming over from Unix. The $ differentiates between commands and data. Commands have symbol substitution and other such, and data does not. And the very first $ that an application reads is treated as an EOF for the application command input.

Unless you need to use a leading $ on your application input data, and then you use $ DECK and $ EOD commands. Which is described here:

http://labs.hoffmanlabs.com/node/1339

Hoff
Honored Contributor

Re: FTP command file issue

ps: please always post your OpenVMS version and architecture. With that detail (for instance, in this case), we can tell if COPY /FTP (or some analogous mechanism) is an option, or whether there are other ways to get the file specification replicated over to the Unix box in the appropriate file case.

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.