09-01-2009 12:23 PM
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)?
Solved! Go to Solution.
09-01-2009 12:39 PM
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?
09-01-2009 12:52 PM
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!
09-01-2009 01:55 PM
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.
$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))"
09-01-2009 01:59 PM
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"
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).
09-01-2009 10:40 PM
is a callable FTP interface.
Never used it myself, but looks promising.
BTW: the "/anonym" option is not available for all VMS FTP clients.