Operating System - OpenVMS
1748088 Members
5073 Online
108758 Solutions
New Discussion юеВ

Re: Rewriting DCL to Perl scripts

 
Kees van der Pot
Occasional Contributor

Rewriting DCL to Perl scripts

Does anybody know of usefull information (like sites, books, other forums) that can help me to rewrite DCL to Perl?
I am just starting with Perl and need to write some command procedures (DCL) in Perl.
So, i like examples very much.
But searching the internet does not help much.
I have access to books42x7, but that is still not helping me. When i find a clou, it's not for VMS. I spend hours of interpreting the examples and writing them for testing. On my laptop, i have more succes then on VMS systems. The things i am looking for is:
- setting my working directory
- test if file exist
- deleting files
- renaming files
all local, and remote with username/passwd.
- get process id
- set process name
- run/detached file.exe
- submit batch.com
- request a message to console
and more.
I want to avoid to make use of systemcalls, for example for starting a dcl procedure:
system('@test.com test_P1');

Please reply if you will share your knowledge!

Thanks, Kees
6 REPLIES 6
Ian Miller.
Honored Contributor

Re: Rewriting DCL to Perl scripts

have you seen
http://webmaster.iu.edu/perl56/vms/perlvms.html
http://search.cpan.org/dist/perl/README.vms
and the VMS specific addons in
http://www.perl.com/CPAN/authors/Dan_Sugalski/

Why are you re-writing DCL scripts into perl?
____________________
Purely Personal Opinion
Ian Miller.
Honored Contributor

Re: Rewriting DCL to Perl scripts

better link for VMS modules

http://www.perl.com/CPAN/modules/by-category/04_Operating_System_Interfaces/VMS/

____________________
Purely Personal Opinion
Hein van den Heuvel
Honored Contributor

Re: Rewriting DCL to Perl scripts

A link I like, which has mosut fuunctions listed you look for:

http://www.xav.com/perl/lib/Pod/perlfunc.html

Be sure to check out the
"alphabetical listing of perl functions"
This starts with the various handy file test operators.

Below a little perl script to get you going on some of the functions you request.

Groetjes,
Hein.


use strict;
use Getopt::Std;

my %opt;
use vars qw/ %out /;

getopts ('tdr:',\%opt) or &usage;
my $file = shift @ARGV or &usage;

if ($opt{t}) {
print "$file is a plain file\n" if (-f $file);
print "$file is a directory\n" if (-d $file);
exit
}

unlink ($file) if ($opt{d});

if ($opt{r}) {
print "New name : $opt{r}\n";
rename $file, $opt{r};
}

sub usage()
{
print STDERR << "EOF";

blah blah...

usage: $0 [-t | -d | r new_nam] filename

-t : test for existance
-d : delete
-r : rename

EOF
exit;
}

Craig A Berry
Honored Contributor

Re: Rewriting DCL to Perl scripts

If you are just starting with Perl I would suggest investing some time getting comfortable with it. I would suggest the O'Reilly book "Learning Perl", as well as the other O'Reilly book "Perl Best Practices".

At least half of what you want to do is not VMS-specific, so just do what you would do for any other platform. For example, to change the current directory:

$ perl -we "chdir('sys$manager'); print `show def`;"
SYS$SYSROOT:[SYSMGR]
= SYS$SYSROOT:[SYSMGR]
= SYS$COMMON:[SYSMGR]

Of the other things in your list, nearly all of it can be done directly from Perl with no need for spawning DCL commands. The list pointed to in Ian's second post has most of what you need. For example, VMS::Queue::submit will submit a batch job for you.

The only thing on the list that I don't know of a way to do offhand is send OPCOM messages -- sounds like someone needs to write another extension to do that.

As far as Ian's question about why convert from DCL to Perl, I don't know Kees's reasons, but there are some advantages. Probably the most significant one is that the whole script is syntax-checked before it is run, unlike DCL where you can have syntax errors hiding in seldom-followed code paths.
Hein van den Heuvel
Honored Contributor

Re: Rewriting DCL to Perl scripts

Ian asked "Why are you re-writing DCL scripts into perl?"

Fair question.

Personally I would never re-write existing DCL into PERL. That seems just a waste.

For new implementations I believe one should consider PERL for those tasks which do a lot of file walking (glob), pattern matching, searching, renaming, deleting and the likes.

On the other hand if every other line is a SUBMIT, COMPILE, LINK or REPLY then just stick to DCL!

An extra reason for leaning towards PERL could be for personal growth/learning.
Someone handy in perl and regexpr ans such is valuable in Unix and Windoze environments.

fwiw,
Hein.

Kees van der Pot
Occasional Contributor

Re: Rewriting DCL to Perl scripts

Whow, what a great response! With thanks to Ian, Hein, and Craig.
Now i need a while to read all the stuff you are pointing to, but i will let you know how i am going.
In answer to the question why i want to use Perl in place of DCL:
We have a kind of monitoring agent that reports events to a monitoring system (both VMS). As a result on that event, the monitoring system point to a script for a action (can be a solution or a data gathering script) this agent must look for this script, fetch and run it. We will expand the platforms to be monitored from VMS-only to include Linux and Windows.
In the period i was learning Perl, it got me by the nose! So, personally, i want to accept the challenge to rewrite each small piece of code and learn about Perl.
So now i have to visit some sites you mentioned, thanks again.