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

DCL script to FTP files

 
ben_moore34
Advisor

DCL script to FTP files

Morning
I wonder if anyone could help me out with modifying a small DCL script which FTPs some files to a server?
We have 8 VAXs which seem to use different FTPs. Some use FTP & some use MULTI FTP as the command to get into the FTP prompt

There is a script which writes commands to a temp file ftpjob.tmp, executes ftpjob.tmp and then deletes it

$ open/write ftpjob ftpjob.tmp
$ wr ftpjob "$ftp 10.37.2.23 /username=ftp_to_share",-
"/password=""1password23"""
$ wr ftpjob "cd /VAX/OUT/SHARE/"
$ wr ftpjob "put ''source_file' ''target_file'"
$ wr ftpjob "bye"
$ wr ftpjob "$exit"
$ close ftpjob
$ @ftpjob.tmp
$! delete ftpjob.tmp;

This works fine on the systems which FTP is accessed by typing FTP


However, on the systems where Multi FTP is typed to access FTP (see below) I get Login or Password incorrect errors.



$ open/write ftpjob ftpjob.tmp
$ wr ftpjob "$multi ftp 10.37.2.23 /username=ftp_legacy_uk_prd",-
"/password=""1pwd4PRDUK"""
$ wr ftpjob "cd /VAX/OUT/APOLLO/"
$ wr ftpjob "put ''source_file' ''target_file'"
$ wr ftpjob "bye"
$ wr ftpjob "$exit"
$ close ftpjob
$ @ftpjob.tmp
$! delete ftpjob.tmp;


If I manually enter the commands at the prompt I can get in, not really sure what I'm doing wrong here..

Any help gratefully received

Thanks

BM


30 REPLIES 30
abrsvc
Respected Contributor

Re: DCL script to FTP files

This may just be a typo, but in the example you posted, multiftp has a space in it which would lead me to believe that the "multi" is recogniozed as invoking multiftp. This means that the "ftp" is being recognized or processed rather than the /username etc.

Please note that I do not have multiftp so I can not test this.

Dan
Steven Schweda
Honored Contributor

Re: DCL script to FTP files

> We have 8 VAXs which seem to use different
> FTPs. [...]

It might be useful to know something about
the software here (more than "VAXs").

Is this "MULTI FTP" related to MultiNet?

The DEC/Compaq/HP IP networking package
should identify itself using a command like:

tcpip show version
or:
ucx show version

depending on its age. MultiNet probably has
something similar, but you may be able to
find that about as fas as I could. ("HELP"?)

At a minimum:

WRITE SYS$OUTPUT F$GETSYI( "VERSION")

Other potentially interesting things:

Did this stuff ever work? If so, what has
changed recently?

Are you publishing real passwords here?

> If I manually enter the commands [...]

And what you enter manually is really what's
in those procedures? As usual, a transcript
showing actual commands with their actual
output can be more helpful than vague
descriptions and interpretations.
Hoff
Honored Contributor

Re: DCL script to FTP files

ftp is an ancient abomination of a protocol and being older than IP itself, is inherently hideous around firewalls, and it has the added bonus of transmitting your username and password credentials in cleartext. All that aside...

If this box is V6.2 or later, you're doing this the hard way.

Use the COPY /FTP command that's available in DCL.

It does symbol substitution.

It does passwords.

It does default directories.

It's trivially easy to use in DCL command procedures, and to substitute symbols within.

COPY /FTP /ASCII -
fromhost"user pass"::"/where/ever.txt" -
localfilename.txt

See the manuals, or see:

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

The more secure version of this operation, which avoids passwords, uses sftp. (There's unfortunately no DCL verb for that, though.) See the sftp documentation or see:

http://labs.hoffmanlabs.com/node/1118
ben_moore34
Advisor

Re: DCL script to FTP files

Thanks for the help so far!

I'm getting somewhere with it

If I issue the following at a command prompt I can get in

Multi ftp 10.37.1.23 /username=username /password="""password""" (I think it needs these quotes to be in the right case)


ATSR22 MultiNet FTP user process V4.0(118)
Connection opened (Assuming 8-bit connections)
<
[Attempting to log in as ******]
FTP>

However I'm trying to run this procedure within a script so that it writes the commands to ftpjob.tmp and then executes it(it's all within an existing procedure which sends lots of reports out)

$ open/write ftpjob ftpjob.tmp
$ wr ftpjob "$Multi ftp 10.37.1.23 /username= username /password="""password""""
$ wr ftpjob "cd /VAX/OUT/SHARE/"
$ wr ftpjob "put ben.txt ben.txt"
$ wr ftpjob "bye"
$ wr ftpjob "$exit"
$ close ftpjob
$ @ftpjob.tmp
$! delete ftpjob.tmp;
$ exit




I'm thinking that somehow it's either submitting the password in the incorrect casing or there's a space missing.

if try for example

Multi ftp 10.37.1.23 /username=******** /password="""****"""

then it'll connect

but if I

open/write benjob benjob.tmp
wr benjob "multi ftp 10.37.1.23 /username= ftp_legacy_uk_prd /password="""1pwd4PRDUK""" "
close benjob


then look inside the benjob.tmp file I have

multi ftp 10.37.1.23 /username= ftp_legacy_uk_prd /password="1PWD4PRDUK"

It has to be something small that I'm missing here I'd imagine

BM
Joseph Huber_1
Honored Contributor

Re: DCL script to FTP files

Is the remote systems username case sensitive ?
If yes, then it must be quoted on the DCL command as well, like the password.
http://www.mpp.mpg.de/~huber
ben_moore34
Advisor

Re: DCL script to FTP files

yes the host has a mixed case password.
It's got to be something to do with how the commands get written into the temp file first and then read back.

Hoff
Honored Contributor

Re: DCL script to FTP files

If the password is causing a problem...

Just get rid of the password.

Why?

At least that's being honest about the security here.
ben_moore34
Advisor

Re: DCL script to FTP files

By the way - some more info on Multi ftp

ATSR19 MultiNet FTP user process V4.0(118)
Connection opened (Assuming 8-bit connections)

ucx show version

DEC TCP/IP Services for OpenVMS VAX Version V4.0 - ECO Level 2
on a VAX 4000-600A running OpenVMS V7.1
The Brit
Honored Contributor

Re: DCL script to FTP files

BM
this is what you are currently doing

Write Outfile "Password="""Test""""

this appears in OutFile as

Password="TEST" (Not what you want!)

Try

Write Outfile "Password=""Test"""
(i.e. one less doublequote around the password string)

Should give;

Password="Test"

HTH

Dave


ben_moore34
Advisor

Re: DCL script to FTP files

Thanks for the answers guys

I'd love to get rid of the password, not my decision unfortunately.
It looks like the command in multi ftp does need the 3""" around the password to recognise it.

OPS> multi ftp 10.37.1.23 /username= ****** /password="""xxxxxx"""
ATSR22 MultiNet FTP user process V4.0(118)
Connection opened (Assuming 8-bit connections)
<
[Attempting to log in as ********]
FTP>exit


The above will let me in

OPS> multi ftp 10.37.1.23 /username= ******** /password=XXXXXXXX
ATSR22 MultiNet FTP user process V4.0(118)
Connection opened (Assuming 8-bit connections)
<
[Attempting to log in as ********]
FTP>exit
OPS>

I have to somehow retain the 3""" when I write the command to the temp file without DCL interpreting them.

Cheers
Oswald Knoppers_1
Valued Contributor

Re: DCL script to FTP files

You have VMS 7.1 so why not try Hoff's suggestion and use copy/ftp. I think both multinet and TCPIP/UCX support this.

Oswald
Joseph Huber_1
Honored Contributor

Re: DCL script to FTP files

It's not easy to communicate the right number of quotes in the ITRC interface ...
and to write the number of quotes correctly in a DCL statement.
I usually do it by putting the quote in a DCL symbol, then use symbol substitution in the WRITE statement, like:

$ Q:= """
$ write file Q,Q,Q,"text",Q,Q,Q

to put text in 3 quotes in the output file.
http://www.mpp.mpg.de/~huber
ben_moore34
Advisor

Re: DCL script to FTP files

Thanks everyone for all the help & suggestions.

Joseph - I set up a symbol as suggested to represent " and it's working now. Took a little bit of messing around

Thanks again & have a good weekend

Cheers

BM I
RBrown_1
Trusted Contributor

Re: DCL script to FTP files


If three pairs of quotes work when done interactively (ie """Test"""), then you will need more quotes inside the command file. It seems to me that for every command level, another set of quotes gets stripped off.

My two cents.
ben_moore34
Advisor

Re: DCL script to FTP files


Yeah I see what you are saying, got it set up like this now & it's working fine

$ Q:= """
$ open/write ftpjob ftpjob.tmp

$ wr ftpjob "$Multi ftp 10.37.1.23 /username= ********",-
"/password=",Q,Q,Q,"XXXXXXX""",Q,Q

$ wr ftpjob "cd /VAX/OUT/SHARE/"
$ wr ftpjob "put ben.txt ben.txt"
$ wr ftpjob "bye"
$ wr ftpjob "$exit"
$ close ftpjob
$ @ftpjob.tmp
$! delete ftpjob.tmp;
$ exit

As a matter of interest do you all use VMS at work? We have a lot of VAXs and a few Alphas here which the company keep threatening to get rid of. Thing is they are so embedded in the infrastructure of the business so it's hard to replace them (keeps me in work for a little longer I guess).

Cheers

BM
Hoff
Honored Contributor

Re: DCL script to FTP files

$ srcfil ="srcfile.txt"
$ trgfil = "trgfile.txt"
$ copy/ftp/ascii -
'srcfil'
10.37.1.23"user pass"::"/HERE/THERE/WHATEVER/''trgfil'"
Hoff
Honored Contributor

Re: DCL script to FTP files

missing hyphen on a continuation...

$ srcfil ="srcfile.txt"
$ trgfil = "trgfile.txt"
$ copy/ftp/ascii -
'srcfil' -
10.37.1.23"user pass"::"/HERE/THERE/WHATEVER/''trgfil'"
ben_moore34
Advisor

Re: DCL script to FTP files

Thanks Hoff

I think in future I'll be using copy/ftp, seems much simpler. I'll probably get asked to modify other scripts before long.

Cheers everyone

BM
Craig A
Valued Contributor

Re: DCL script to FTP files

The last time I looked at this in any great detail (and that is a good couple of years ago) I decided against COPY/FTP because I wanted to trnasfer the file over as a .TMP file and then RENAME it to its correct extention.

Since I would need to establish a connection to do the rename I just did it as follows:

PUT CRAIG.DAT CRAIG.TMP
RENAME CRAIG.TMP CRAIG.DAT

The advantage of this approach is that if the network connection breaks part-way through the transmit, there isn't a correctly named file left overhanging. Many of the processes were automated and would poll incoming folders for specific files. Not good.

HTH

Craig
Robert Gezelter
Honored Contributor

Re: DCL script to FTP files

Ben,

Personally, I have used bare FTP and COPY/FTP. As Hoff has noted, whether COPY/FTP exists depends on the version of OpenVMS with which one is dealing.

That said, if one is dealing with different versions of invoking FTP, in many cases one can deal with this by defining a DCL symbol for FTP (e.g., FTPUTILITY to avoid confusion) whose value is either "FTP" or "MULTINET FTP" (or others) depending on what is available on that node. That way, the dependency is limited to a a highly localized point in the script (you may guess why I make this recommendation).

I do not disagree with Hoff's comments, however, FTP is often used as a lingua franca between a variety of systems, and thus may be unavoidable, despite its age and admitted security-related drawbacks.

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

Re: DCL script to FTP files

Though MultiNet 4.0 is very old, it looks like it should support COPY/FTP.
John Gillings
Honored Contributor

Re: DCL script to FTP files

Seconding (or 3rd or 4th) to use COPY/FTP - it covers most cases. If you have something tricky, say creating directories, instead of writing a file from your procedure then executing it, just write it to SYS$OUTPUT

FTPCMD.COM
$ wo="WRITE SYS$OUTPUT"
$ wo "cd /VAX/OUT/SHARE/"
$ wo "put ''source_file' ''target_file'"
$ wo "bye"

You can execute the procedure and PIPE it into an FTP command to be executed:

$ PIPE @FTPCMD | -
FTP/INPUT=SYS$PIPE 10.37.2.23 /username=ftp_to_share/password="1password23"

The PIPE can, of course be inside a procedure. Saves all the hassle of dealing with temporary files.
A crucible of informative mistakes
Sam Samalsson
Occasional Visitor

Re: DCL script to FTP files

$ copy /ftp /log /ascii -
$1$dga418:[ftp.temp]*.*;* -
192.168.249.12"UserName PassWord"::"ftp-temp/"

You may use logicals and/or symbols instead
og the specifics
The Brit
Honored Contributor

Re: DCL script to FTP files

The other BIG advantage of using the "copy/ftp" command is that it returns $status and $severity, which allows error handling on failed copies. (this is much more complicated when using FTP from within a command file).

Dave.