Re: function in cobol for execute s.o. commands (140 Views)
Reply
Frequent Advisor
Edgar Ulloa
Posts: 73
Registered: ‎05-04-2005
Message 1 of 8 (140 Views)
Accepted Solution

function in cobol for execute s.o. commands

Hi
I have a I64VMS COBOL V2.8-1380 under ovms 8.3 1h1

my question is

some one knows any function or lexical o utility that let to me execute a vms command inside of my cobol program (dir,@,show etc)?

regards
Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,063
Registered: ‎02-23-2005
Message 2 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

One possibility: LIB$SPAWN

HELP RTL_Routines LIB$ LIB$SPAWN

SYS$EXAMPLES may contain some example C code.
COBOL could be harder to find.

Where did you want the output to go?
Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,580
Registered: ‎05-19-2003
Message 3 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

As Steven indicates, LIB$SPAWN (or its core service SYS$CREPRC can execute commands.

However, while you phrase the problem very generically, I wonder whether you have a specific problem in mind.

I ask this because many OpenVMS task have a calleable interface, which typically allows much more control for perhaps a little bit more coding work.

Specifically you may want to use LIB$FIND_FILE or SYS$PARSE + SYS$SEARCH to find files like 'dir', and SYS$GETJPI (or LIB$GETJPI) to do SHOW PROCESS style work.
For a commadn file (@) you would need LIB$SPAWN or perhaps start it as a batch job? ( SYS$SNDJBC )

So what problem are you really trying to solve?

My last customer to ask the question how to call @ from Cobol actually wanted to run a command file which they always used to clear the screen... Cobol has that build in!

hth,

Hein
Please use plain text.
Frequent Advisor
Edgar Ulloa
Posts: 73
Registered: ‎05-04-2005
Message 4 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

Basicly this command I would like execute

$copy/ftp/anon arch.dat 10.x.x.x::comdet'dato1''dato2''dato3'.pf8

regards
Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,580
Registered: ‎05-19-2003
Message 5 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

Yeah, then you'd best just use LIB$SPAWN
Use the cobol 'STRING' verb to glue together a commandline (pieces DELIMITED BY SIZE (or 'delimiter), passing that by descriptor.
Or use SYS$FAO to cobble together a string from multiple pieces.

It's kinda lame there is no calleable FTP, but there isn't.
Perl has a module implementing am FTP client, but that does not help you much.

Hein.

$perl -e "use Net::FTP; $x=Net::FTP->new (q(10.x.x.x)); $x->login(q(user),q(pass)); $x->get(q(tmp.tmp))"

Please use plain text.
Honored Contributor
John Gillings
Posts: 2,992
Registered: ‎07-31-2003
Message 6 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

Edgar,

Unfortunately COPY doesn't have a callable interface. For a normal copy, you can get by with callable convert CONV$CONVERT, but that won't help you with COPY/FTP.

I'm not aware of any callable interface for FTP, other than talking the protocol yourself using sockets. So, you're really left with SPAWN. In its simplest form in COBOL it would look something like:

CALL "LIB$SPAWN" USING BY DESCRIPTOR "copy/ftp/anon arch.dat 10.x.x.x::comdet'dato1''dato2''dato3'.pf8"
GIVING SpawnStatus

of course, you can build up the string in a variable and pass it, but be careful to make sure the descriptor gets the correct length.

Any output, including error messages would go to SYS$OUTPUT. See the LIB RTL manual for details of the (many) other arguments.

Also note that this will only work from a process with a CLI (includes interactive, batch and network processes, but not all detached processes).
A crucible of informative mistakes
Please use plain text.
Honored Contributor
Joseph Huber_1
Posts: 1,082
Registered: ‎02-03-2004
Message 7 of 8 (140 Views)

Re: function in cobol for execute s.o. commands


http://nbpfaus.net/~pfau/ftplib/

is a callable FTP interface.

Never used it myself, but looks promising.

BTW: the "/anonym" option is not available for all VMS FTP clients.
http://www.mpp.mpg.de/~huber
Please use plain text.
Frequent Advisor
Edgar Ulloa
Posts: 73
Registered: ‎05-04-2005
Message 8 of 8 (140 Views)

Re: function in cobol for execute s.o. commands

Thanks for your time

now used another external aplication for transfer.

cheers
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation