Operating System - OpenVMS
1822894 Members
3653 Online
109645 Solutions
New Discussion юеВ

FTP script for transferring files from OpenVMS to Unix server

 
Tejas J Raval
Advisor

FTP script for transferring files from OpenVMS to Unix server

Dear All,

I want to create a ftp script to transfer files from OpenVMS to Solaris server.
Since I haven't done scripting before I am stuck up.

Does any one have any script that is used to do the needfull.

17 REPLIES 17
Robert Gezelter
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Tejas,

While I cannot take the time to write the script for you, I can refer you to the appropriate places to get the information.

First, the OpenVMS documentation set is online at http://www.hp.com/go/openvms

Second, presuming that you are using the HP IP stack, then you will find that the FTP command will has a variety of command line options, including USERNAME, PASSWORD, and INPUT. These allow you to script the actual FTP session. Combined with the facilities in DCL (the OpenVMS command language and scripting facility) you can perform extensive processing. PERL and other tools are also available for OpenVMS and may be on your system.

There have also been a variety of presentations on writing scripts in DCL, including my "DCL Jujitsu" presentation at the the Fall 1995 US DECUS symposium. The slides from that presentation are available at http://www.rlgsc.com/decus/usf95/index.html

I hope that the above is helpful.

- Bob Gezelter, http://www.rlgsc.com
Richard Brodie_1
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Using COPY/FTP (on a reasonably modern OpenVMS system) can avoid the need to write a more complex script.
Heinz W Genhart
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Hi Tejas

A commandfile like this one

$ SET TERM/NOECHO
$ READ SYS$COMMAND password/Prompt="Enter Password "
$ WRITE SYS$OUTPUT ""
$ SET TERMINAL/ECHO
$ FTP obelix /user=users-name/password='password'/input=get.com

will set the terminal to noecho, ask the users password and will start FTP, where /user must contain the username /password contains the password of the user. The FTP Command will execute the commands supplied within COmmandfile GET.COM which looks like this:

typ get.com
get login.com
exit

In this case we transfer the login.com from the remote machine to the local machine in ascii mode.

Hope that helps

Regards

Heinz
Vouters
Advisor

Re: FTP script for transferring files from OpenVMS to Unix server

PROCEDURE NOTES:

This command procedure accepts six procedure parameters:
- P1 the remote IP node name or address in Internet notations.
- P2 the remote USERNAME. If casing is to be preserved, pass
the username betweeen quotes.
- P3 the remote PASSWORD. If casing is to be preserved, pass
the password betweeen quotes.
- P4 the local VMS FILENAME. The filename and file extension
are extracted from this string. Therefore, if remote file
is to be passed in lowercase enclose the string between
quotes.
- P5 the transfer operation (i.e. : GET or PUT)
- P6 the transfer mode (i.e.: ASCII or IMAGE)
- P7 (optional) the target remote directory

PROCEDURE:

$! COPYRIGHT (C) 1998 BY
$! COMPAQ COMPUTER CORPORATION, HOUSTON
$! TEXAS. ALL RIGHTS RESERVED.
$!
$! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
$! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
$! OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
$! THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
$! PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
$!
$! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
$! SHOULD NOT BE CONSTRUED AS A COMMITMENT BY COMPAQ COMPUTER CORPORATION.
$!
$! COMPAQ ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
$! SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY COMPAQ.
$!
$! NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE
$! ON EQUIPMENT THAT IS NOT SUPPLIED BY COMPAQ COMPUTER CORPORATION.
$!
$! SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY COMPAQ SOFTWARE
$! PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE
$! CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED.
$!
$! Command procedure pararameter:
$! P1 the remote IP node name or address in Internet notations.
$! P2 the remote USERNAME. If casing is to be preserved, pass the username
$! betweeen double-quotes.
$! P3 the remote PASSWORD. If casing is to be preserved, pass the password
$! betweeen double-quotes.
$! P4 the local VMS FILENAME. The filename and file extension is extracted
$! from this string. Therefore, if remote file is to be passed in lowercase
$! enclose the string between double-quotes.
$! P5 the transfer opration (i.e. : GET or PUT)
$! P6 the transfer mode (i.e.: ASCII or IMAGE)
$! P7 the target directory (optional).
$!
$ file = P4
$ colon = f$locate(":",file)
$ if colon .ne. f$length(file)
$ then
$ file = f$extract(colon+1,f$length(file) - colon, file)
$ endif
$ close_bracket = f$locate ("]",file)
$ if close_bracket .ne. f$length(file)
$ then
$ file = f$extract(close_bracket+1,f$length(file) - close_bracket,file)
$ endif
$ file = f$extract(0,f$locate(";",file),file)
$ open/write fred ftp.com
$ write fred "$ftp ''P1'/username=""''P2'""/password=""''P3'"""
$ if P7 .nes. ""
$ then
$ write fred "cd ''P7'"
$ endif
$ write fred "type ''P6'"
$ if P5 .eqs. "GET"
$ then
$ if f$locate("*",file) .eq. f$length (file) -
.and. f$locate("...",P4) .eq. f$length(P4)
$ then
$ write fred "get ""''file'"" ''P4'"
$ else
$ write fred "mget ''P4'"
$ endif
$ else
$ if f$locate("*",file) .eq. f$length (file) -
.and. f$locate("...",P4) .eq. f$length(P4)
$ then
$ write fred "put ''P4' ""''file'"""
$ else
$ write fred "mput ''P4'"
$ endif
$ endif
$ write fred "bye"
$ close fred
$ @ftp
$ delete ftp.com;*
$ exit

Hoping this shall help you.
Regards,
Philippe
Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

The classic FTP command mode utility is comparatively more involved and more difficult to use, while the COPY/FTP interface (a feature of OpenVMS releases for the last dozen years or so) can provide full DCL integration for usernames and passwords. And the command looks and works like COPY and other typical DCL commands, including symbol substitution. Unlike FTP command mode utility.

I cannot recommend it strongly enough: use COPY/FTP.

Unless you really need it -- such as you're working on an ancient OpenVMS VAX (pre-V6.2) release -- I'd encourage you to treat the FTP utility as deprecated.

Basic command syntax:
COPY/FTP from to

The from or to parameters can include the IP host name and the username and password.

The following shows how to perform a network transfer, and how to specify a foreign file specification:
COPY/FTP login.com x.y.z"usr pw"::"/tmp/login.com"

With DCL and OpenVMS command parsing, the /tmp target shown can't be specified straight away, so it's quoted. The host name and username and password syntax -- the stuff to the left of the :: -- follows that of DECnet.

What you'd expect to find with an FTP transfer including /PASSIVE, /BINARY, etc., are available on the command line. OK, /PASSIVE is somewhat newer than V6.2, IIRC.

As for the core question, there are tutorial sites and various Unix to DCL command comparisions referenced in the OpenVMS FAQ. If you can find a copy (it seems to go in and out of print), there's the book I wrote a while back, Writing Real Programs in DCL 2nd Ed. In the OpenVMS manual set (an excellent resource) there's the OpenVMS User's Guide. There are piles of code examples on the OpenVMS Freeware distros, as well as other sites around the network.

There are also classes and such available for OpenVMS.

Stephen Hoffman
HoffmanLabs
Tejas J Raval
Advisor

Re: FTP script for transferring files from OpenVMS to Unix server

Hi Friends,

Thanks for your advice. I was able to transfer files using following script.

OPENVMS to Solaris file transfer using FTP script. [15-Feb-07]



$! Program for copying files from VMS to UNIX
$ set on
$ on warning then goto error_ftp
$ ftp sandbox01 /username=TESTUSER /password=R0M0KRIS
lcd dka300:[sys0.SYSCOMMON.SYSMGR.TRAVAL]
cd /export/home/TESTUSER
mput ftp.com;*
exit
$ goto exit
$ error_ftp:
$ write sys$output "Da the file didn't get transfered"
$ exit:
$ exit


Observations: 1) Accepts username & password in Caps only.However if I FTP from system prompt it work's with small caps also.

2) Copies multiple version but replaces semicolon (;) with period (.)

Kindly help me in resloving Caps & semicolon issue.


Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Lowercase?

I'd use COPY/FTP. It inherently deals with lowercase password strings.

COPY/FTP deals with DCL symbol substitution, something most folks will eventually want to use. If you don't have DCL symbol substitution (because you're inside a utility such as FTP, and DCL is not reading and processing your command input), you end up generating external files containing commands, and invoking them.











Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server


One liner:

$ copy/ftp
dka300:[sys0.SYSCOMMON.SYSMGR.TRAVAL]FTP.COM
sandbox01"TestUser r0m0Kris"::"/export/home/TESTUSER/FTP.COM"



Daniel Fernandez Illan
Trusted Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Hi

You can use lowercases on username and password options writing values between quotation marks.

By default VMS use uppercase texts and generally does not have differences between lower and upper cases on commands.

FTP client converts ";" to "." on Solaris server.

Saludos.
Daniel.
Tejas J Raval
Advisor

Re: FTP script for transferring files from OpenVMS to Unix server

Dear Hoff,

Copy/ftp worked thanks a lot.

Dear Daniel,

I am trying your option.

Thanks & Regards,

Tejas
Tejas J Raval
Advisor

Re: FTP script for transferring files from OpenVMS to Unix server

Daniel,

After putting username & password in "" authentication problem got solved.

But when file gets copied to Solaris server it changes to CAP. File is displayed in CAPS & ; is replaced with .



Presently it display's
root@sandbox01 # ls -l
total 38550
-rw-r--r-- 1 traval staff 324 Feb 16 07:28 FTP.COM.16



Should be

root@sandbox01 # ls -l
total 38550
-rw-r--r-- 1 traval staff 324 Feb 16 07:28 ftp.com;16


Kindly suggest.Thx for your help.


Regards,

Tejas J Raval





Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

If the target on the remote host was in caps and you used the COPY/FTP command I showed, then try the following variation:

$ copy/ftp
dka300:[sys0.SYSCOMMON.SYSMGR.TRAVAL]FTP.COM
sandbox01"TestUser r0m0Kris"::"/export/home/TESTUSER/ftp.com"

The Unix variant I most frequently use is case-blind and case-preserving, which avoids this particular aspect.

OpenVMS can select a similar case-blind case-preserving with the SET PROCESS /PARSE=EXTEND command and with the ODS-5 volume structure. This is the second approach toward your goals; to enable the extended (EFS) parsing and syntax.

There are logical names which can control the specific behavior of FTP itself around version numbers and related. The TCP/IP Services manuals are at http://www.hp.com/go/openvms/doc/ and the logical names are in the management manual, in the chapter on FTP server configuration and management. There's a rather long list of knobs, um, logical names that can be adjusted to meet your specific needs.
Steven Schweda
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

> FTP client converts ";" to "." on Solaris
> server.

Ok. This _can't_ be true (or so I assumed),
so I fired up my SunOS 5.10 on my Ultra-60,
figured out that my long-standing FTP server
problem there was that "in.ftpd" _requires_
"/etc/shells", so I created one of those, and
then tried sending a file with a ";" in its
name.

I'm open to a better explanation, but it
appears to me that the VMS (TCPIP) FTP client
does some clever (?) name parsing on a PUT
_destination_ file spec, and transforms
anything which looks like a VMS version
number into ".version" instead of leaving it
as ";version". Quotation doesn't seem to
help. I'll admit that most people would
prefer UNIX file names without semi-colons,
but the same is true of "$", and those get
passed along with no argument. I'd argue
that it should be _possible_ to get a
semi-colon at the other end, too.

A quick look (SEARCH ... DECC$) at my
SYS$COMMON:[SYSEXE]TCPIP$FTP_CLIENT.EXE
shows a bunch of DECC$feature names, like:

DECC$FILENAME_UNIX_ONLY
DECC$SET_FILESPEC_STYLE
DECC$EFS_CASE_PRESERVE

If it's setting these things internally, then
there may be no way for a user to get it to
do the right thing (where "right" is what I'd
like it to do, namely, stop "helping" me).

Note that a non-version semi-colon _is_
preserved, for example:

FTP> put SEMI_COLON.;1 semi;colon
200 PORT command successful.
150 Opening ASCII mode data connection for semi;colon.
226 Transfer complete.
local: ALP$DKA0:[SMS]SEMI_COLON.;1 remote: semi;colon

or even:

FTP> put SEMI_COLON.;1 semi;colon;1
200 PORT command successful.
150 Opening ASCII mode data connection for semi;colon;1.
226 Transfer complete.
local: ALP$DKA0:[SMS]SEMI_COLON.;1 remote: semi;colon;1
6 bytes sent in 00:00:00.00 seconds (5.86 Kbytes/s)

but Mr. Know-it-all outsmarts us on a simple
one:

FTP> put SEMI_COLON.;1 SEMI_COLON.;1
200 PORT command successful.
150 Opening ASCII mode data connection for SEMI_COLON..1.
226 Transfer complete.
local: ALP$DKA0:[SMS]SEMI_COLON.;1 remote: SEMI_COLON..1
6 bytes sent in 00:00:00.00 seconds (5.86 Kbytes/s)


Once upon a time (10-DEC-2004, more or less),
I did a little work on a (freeware) program
called "wput" (intended to be like "wget"
facing the wrong way). I never pushed it
very far, as it seemed pointless on VMS, what
with COPY /FTP and all. However, if you
really want full control over an FTP
destination file name, it's starting to look
better all the time ("-A" for ASCII, with
SET PROC /PARS = EXTE):

alp $ wput -A SEMI_COLON.;1 ftp://sms:my_password@sol/semi_colon;123
--12:09:51-- `SEMI_COLON.;1'
=> ftp://sms:xxxxx@10.0.0.38:21/semi_colon;123
Connecting to 10.0.0.38:21... connected!
Logging in as sms ... Logged in!
Length: 6

100%[====================================] 6
12:09:51 (semi_colon;123) - `39.90B/s' [6]

sol> ls -l semi*
-rw-r--r-- 1 sms 15 5 Feb 16 12:11 semi_colon;123


For the record:

alp $ tcpip show version

HP TCP/IP Services for OpenVMS Alpha Version V5.4 - ECO 6
on a COMPAQ Professional Workstation XP1000 running OpenVMS V7.3-2

Perhaps it's all better in V5.6.

Interestingly, RENAME seems to work (in the
interactive FTP client):

FTP> rename SEMI_COLON..1 SEMI_COLON.;1
350 File exists, ready for destination name
250 RNTO command successful.

sol> ls -l SEMI*
-rw-r--r-- 1 sms 15 5 Feb 16 12:20 SEMI_COLON.;1

I don't know how you'd do that with COPY /FTP.
Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

There exists a small forest of TCP/IP Services FTP Server logical names; of FTP server control knobs:

http://h71000.www7.hp.com/doc/83final/6526/6526pro_041.html#ftp_logicals_sec

For file version processing within the TCP/IP Services FTP server, the usual knob is the TCPIP$FTP_NO_VERSION logical name.

For the TCP/IP Services FTP client, if you're seeing dots in the remote spec in front of the version, then the store-unique (sunique) option is likely coming into play. Details are here:

http://h71000.www7.hp.com/doc/732FINAL/6525/6525pro_002.html

Steven Schweda
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

> [...] store-unique (sunique) [...]

Ah. Foolishly, I looked at the HELP, and saw
nothing relevant. However, while it's
probably involved, changing it seems not to
affect this particular behavior:

FTP> sunique
Store unique on.
FTP> sunique off
Store unique off.
FTP> put SEMI_COLON.;1 SEMI_COLON.;1
200 PORT command successful.
150 Opening ASCII mode data connection for SEMI_COLON..1.
226 Transfer complete.
local: ALP$DKA0:[SMS]SEMI_COLON.;1 remote: SEMI_COLON..1
6 bytes sent in 00:00:00.00 seconds (5.86 Kbytes/s)


sol> ls -l SEMI*
-rw-r--r-- 1 sms 15 5 Feb 16 13:00 SEMI_COLON..1
Hoff
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

FWIW, the IP manual indicates sunique is always involved to some degree, and based on the target system identification and on the associated OpenVMS file specification.

If you specify an OpenVMS file with a version specification included and the target is not OpenVMS, OpenVMS FTP is (still) going to try to provide the version number.
Steven Schweda
Honored Contributor

Re: FTP script for transferring files from OpenVMS to Unix server

Of course, "provide the version number" is
one thing, and "re-format the version number"
is another.

The semi-colon -> dot conversion may be a
good plan most of the time, as the results
resemble what the NFS server offers, for
example, but it's not the only useful option,
I claim.

Note, for comparison, that the new Zip 3.0 on
VMS will (most likely) offer a new "-ww"
option (to go with the older "-w"):

-w store file version numbers
-ww store file version numbers as ".nnn"

and UnZip 6.0 will (most likely) offer a new
"-Y" option:

-Y treat ".nnn" as ";nnn" version

But these things are _options_.