Operating System - OpenVMS
1751949 Members
4664 Online
108783 Solutions
New Discussion юеВ

Re: Using Perl on OpenVMS for remote file access

 
Kees van der Pot
Occasional Contributor

Using Perl on OpenVMS for remote file access

Is there a solution for the DCL command: dir node"user passw"::disk:directory:[000000]file.ext ? We like to rewrite some DCL scripts into Perl and therefore we need to do file manipulation via DECnet and also via TCP on remote nodes. Will someone give me a start?
6 REPLIES 6
Craig A Berry
Honored Contributor

Re: Using Perl on OpenVMS for remote file access

Perl on VMS generally understands native filespecs, so I would just try using your fully specified names including nodename. Here's an example that works for me:

$ perl -e "@a = glob '0""user password""::sys$manager:*.dat'; print join qq/\n/, @a;"
0"user password"::sys$sysroot:[sysmgr]accountng.dat
0"user password"::sys$sysroot:[sysmgr]decw$terminal_default.dat
0"user password"::sys$sysroot:[sysmgr]iogen$prefix.dat
0"user password"::sys$sysroot:[sysmgr]vmsimages.dat
0"user password"::sys$common:[sysmgr]amds$driver_access.dat
0"user password"::sys$common:[sysmgr]decw$autoconfig.dat
0"user password"::sys$common:[sysmgr]decw$fs_config.dat
0"user password"::sys$common:[sysmgr]decw$rgb.dat
0"user password"::sys$common:[sysmgr]dtss$config_template.dat
0"user password"::sys$common:[sysmgr]net$configure-lock.dat
0"user password"::sys$common:[sysmgr]vms$audit_server.dat
0"user password"::sys$common:[sysmgr]vms$images_master.dat
0"user password"::sys$common:[sysmgr]vmsimages.dat

As far as TCP/IP using Perl, that shouldn't really be any different on VMS than on other platforms.
Hein van den Heuvel
Honored Contributor

Re: Using Perl on OpenVMS for remote file access

Kees,

As Craig writes, just use 'glob' and 'stat' and 'open' as normal and provide with a remote filespec.

And of course you can always use the back-ticks:

perl -e "print foreach (`dir 0""hein password""::login.com`)"

So what did you try?
What seemed to be the problem?
Any error messages?
Any behaviour you can not explain or deal with?

Groetjes,
Hein.
Kees van der Pot
Occasional Contributor

Re: Using Perl on OpenVMS for remote file access

Hello, thanks for your reply, both.

It is not working as expected. Here are my findings:
This command is silently not working with -e, so i made it to be -w. See result:
perl -w "@a = glob '0""kees password""::pcmrar_ontw:[exe]*.exe'; print join qq/\n/, @a;"
Can't open perl script "@a = glob '0"kees password"::pcmrar_ontw:[exe]zip.exe'; print join qq/\n/, @a;": file

specification syntax error
%RMS-F-SYN, file specification syntax error

Tryed to put it in a script (one.pl):

@a = glob('0""kees password""::pcmrar_ontw:[exe]*.exe');
foreach(@a)
{
my $bewerk = $_;
print("glob vond $bewerk\n");
}

$ perl -w one.pl
glob failed (can't start child: invalid argument) at one.pl line 1.

Perl Version:
perl -V

This is perl, v5.8.6 built for VMS_AXP

The other suggestion works, but i am not able to make a script of it.
perl -e "print foreach (`dir 0""kees password""::pcmrar_ontw:[exe]zip.exe`)"

Directory 0"kees password"::PCMRAR_ONTW:[EXE]

ZIP.EXE;641 197 31-JAN-2000 14:29:11.09

Total of 1 file, 197 blocks.

Here i want to see if there are warnings, now it's not working anymore.

perl -w "print foreach (`dir 0""kees password""::pcmrar_ontw:[exe]zip.exe`)"
Can't open perl script "print foreach (`dir 0"kees password"::pcmrar_ontw:[exe]zip.exe`)": file specification

syntax error
%RMS-F-SYN, file specification syntax error
Hein van den Heuvel
Honored Contributor

Re: Using Perl on OpenVMS for remote file access


Kees,

Try putting the perl in a script first.

I like using the -e for 'one liners' a lot, but the quotes can easily get too confusing.

The double quotes (for the name/pass) in the quoted string (for the filespec) in the quoted string (for the program) gets you about 3 levels deep and wondering whether you need to double up or triple up or what.

On a Unix platform you can put the program itself in single quotes, and use double quotes for interpretted symbols withing the program. However, on VMS the single quotes on hte command line start a substitution so can not be used.

fwiw,
Hein.
Craig A Berry
Honored Contributor

Re: Using Perl on OpenVMS for remote file access

Kees,

The -w switch cannot be substituted for the -e switch. -w enables warnings and -e instructs Perl to run a "one-liner", i.e., take a string from the command line as a program instead of expecting the name of a file containing a program. You can certainly use them together, however:

$ perl -we "$x = 'hello'; "
Name "main::x" used only once: possible typo at -e line 1.


The problem in your one.pl script is that you left in the doubled up double quotes, which is necessary when DCL sees the string before Perl does, but dead wrong otherwise. As Hein points out, one-liners of any complexity can put you in a strange world that is the intersection of DCL syntax and Perl syntax; you need to be pretty comfortable with both to survive there.
Kees van der Pot
Occasional Contributor

Re: Using Perl on OpenVMS for remote file access

Thanks Craig and Hein,

I spend a lot of time expirimenting with quotes, but it is not working.

But i found a way to get files from a remote host with FTP.
The problem is that i want to rewrite DCL scripts to Perl and try to avoid using system calls. Now i spend a lot of time searching the internet for solutions and find that if there is one for windows or unix, its not working on VMS.

Thanks again! (i will make a new thread about Perl in VMS)