Operating System - OpenVMS
1748210 Members
2744 Online
108759 Solutions
New Discussion юеВ

function in cobol for execute s.o. commands

 
SOLVED
Go to solution
Edgar Ulloa
Frequent Advisor

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
7 REPLIES 7
Steven Schweda
Honored Contributor
Solution

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?
Hein van den Heuvel
Honored Contributor

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
Edgar Ulloa
Frequent Advisor

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
Hein van den Heuvel
Honored Contributor

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))"

John Gillings
Honored Contributor

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
Joseph Huber_1
Honored Contributor

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
Edgar Ulloa
Frequent Advisor

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

Thanks for your time

now used another external aplication for transfer.

cheers