Operating System - OpenVMS
1831289 Members
3164 Online
110022 Solutions
New Discussion

How to get the status of a FTP command

 
Pallavi Akundi
Occasional Advisor

How to get the status of a FTP command

Hello,

I have just joined this forum and am a novice to this field, therefore any help on this would be greatly appreciated.

My requirement is that I need to capture the success/failure of an FTP operation into a variable in a command procedure. Typically if the FTP address that I am requesting is not available.

The $status and $severity variables are always showing as normal even if the ftp address is not available and FTP has timed out. I even tried using the spawn command to capture the status, but the same hasn't worked. Please help

Code example :
----------------------------------------------
$ ftp xxx.xxx.xxx.xxx
XXX.XXX.XXX.XXX: %MULTINET-F-ETIMEDOUT, Connection timed out
ftp>spawn
$ status = f$message ($status)
$ sho symbol status
STATUS = "%NONAME-W-NOMSG, Message number 00000000"
$ severity = $severity
$ show symbol severity
SEVERITY = "1"
$ log off
FTP> exit
$ status = f$message ($status)
$ show symbol status
STATUS = "%SYSTEM-S-NORMAL, normal successful completion"
$ severity = $severity
$ show symbol severity
SEVERITY = "1"
----------------------------------------------
Even though the ftp has timed out as the server was not available, the staus was normal completion. How to capture the correct status.
People with goals succeed because they know where they are going-- as quoted by some one
11 REPLIES 11
Volker Halle
Honored Contributor

Re: How to get the status of a FTP command

Pallavi,

OpenVMS only returns the EXIT status of an image into the DCL $STATUS symbol. If you spawn a subprocess, your main image does not exit, so you can't see it's status value.

Depending on your OpenVMS version and your TCPIP stack, you can execute some FTP commands using their OpenVMS equivalent DCL commands, e.g.:

$ DIR/FTP or $ COPY/FTP

These command would then return at least success/failure status.

Another way may be to write a little DCL command file with FTP commands and run this mini-procedure with SYS$OUTPUT assigned to a temp file, then parse the temp file for FTP status/errors.

Volker.
Phil.Howell
Honored Contributor

Re: How to get the status of a FTP command

When you spawn, you lose the current status

_TNA6:tcpip show ver

Compaq TCP/IP Services for OpenVMS Alpha Version V5.1 - ECO 1
on a AlphaStation 200 4/166 running OpenVMS V7.2-1

_TNA6:ftp xxxxxxxxx.xxx
%TCPIP-E-FTP_NETERR, I/O error on network device
-TCPIP-W-TRY_AGAIN, name server experienced temporary error, retry operation
_TNA6:sts=$status
_TNA6:show sym sts
STS = "%X17649ABA"

Phil
Marc Van den Broeck
Trusted Contributor

Re: How to get the status of a FTP command

Hi,

ftp does return status info.
I use following procedure:

$on warning then goto error_proc
$FTP ftp_server_name
username
Password
PUT ...
EXIT
$ ... everything went OK
$EXIT
$error_proc:
$IF ($STATUS .EQS. "%X17649AAA") .OR. ($STATUS .EQS. "%X17649ABA")
$THEN
$ ... login or connection error
$ELSE
$ ... some other error like file or directory problem
$ENDIF
$EXIT

Rgds
Marc
Steven Schweda
Honored Contributor

Re: How to get the status of a FTP command

I'd look into COPY /FTP, as already
suggested. Also, if you're always fetching
files instead of sending them, then a
program like wget or curl might be useful.

http://antinode.org/dec/sw/wget.html
http://curl.haxx.se/

There exists a program called wput (for
sending files), but I haven't looked at it
for a long while, and with COPY /FTP, there's
not much need for it on VMS.
Richard Whalen
Honored Contributor

Re: How to get the status of a FTP command

Part of his problem is that MultiNet's FTP does not exit its command loop when there is a failure to connect when the target is specified on the DCL command line.
The COPY/FTP command, or
ftp hostname put foo
will exit with a failure status as desired.
If there is a desire to do many FTP commands, then I would recommend that the /TAKE_FILE qualifier be used and that the file include "EXIT-ON-ERROR" as the first command. This will cause FTP to exit due to the error in connecting. If you desire to ignore errors after the connect, then another "EXIT-ON-ERROR" command will turn off this functionality.
Pallavi Akundi
Occasional Advisor

Re: How to get the status of a FTP command

Hello,

I have tried the examples given, however for some reason I did not get a STATUS = "%X17649AAA" OR STATUS = "%X17649ABA". I have written a command procedure as suggested:
--------------------------------------------
$ SET ON
$on warning then goto error_proc
$FTP ftp_server_name/user="username"/pass="Password"
EXIT
$ write sys$output "Job completed successfully"
$EXIT
$error_proc:
$IF ($STATUS .EQS. "%X17649AAA") .OR. ($STATUS .EQS. "%X17649ABA")
$THEN
$ write sys$output "login or connection error"
$ELSE
$ Write sys$output "some other error like file or directory problem"
$ENDIF
$EXIT

I had given the FTP details with the wrong password. The FTP prompt showed an error saying invalid login information but the command proc ended showing job completed successfully.

One question, has this got to do with the version of the Multinet FTP that is running on my server?
People with goals succeed because they know where they are going-- as quoted by some one
Thomas Ritter
Respected Contributor

Re: How to get the status of a FTP command

My perferred approach is have it all on one command line and then check the status by checking only for the first bit being high. Works in all cases so far under vms 7.3-2 and UCX 5.4+

$ ftp 192.168.0.5 /username="test" /password="secret"/input=ftp.com
$ if .not. $severity .AND. 1 !not successful

Many times the input file contains variable data. Create the input file at runtime and delete at completion.
Steven Schweda
Honored Contributor

Re: How to get the status of a FTP command

Of course, ".AND. 1" is only for show, as IF
tests that bit. For example:

alp $ if 0 then write sys$output "True"
alp $ if 1 then write sys$output "True"
True
alp $ if 2 then write sys$output "True"
alp $ if 3 then write sys$output "True"
True
[...]
Richard Whalen
Honored Contributor

Re: How to get the status of a FTP command

The "$ WRITE SYS$OUTPUT" after the FTP in your most recent command procedure will change the value of the $status symbol. You need to check the value of $status immediately upon termination of the program/command in question.

Richard Whalen
Honored Contributor

Re: How to get the status of a FTP command

The version of MultiNet on the server wouldn't matter, but the fact that you are running MultiNet on your VMS client will change the status values.

I just did a test connect (to a node that I knew was down) and got %X100081E4 for a status. When I used a bad password I got %x1212002c.

This was all done with specifying the username and password on the command line with a /take_file and the take_file containing the EXIT-ON-ERROR, CONNECT and other commands.
Pallavi Akundi
Occasional Advisor

Re: How to get the status of a FTP command

Hello all,

Thanks a Lot for all the support.

Regards,
Pallavi
People with goals succeed because they know where they are going-- as quoted by some one