neckha...@penntraffic.com wrote:
Hi guys,

Hello,

I am starting to learn Perl as the ksh scripting language (which I
don't know either) looks less than powerful.

I have used C many years ago, and write my stuff in REXX on a
mainframe, so Perl looks like the best of both worlds.

My environment is AIX 5.3 running some sort of 5.8 PERL. Oh hell, let
me check..... 5.8.2.

Most of the documentation and tutorials I find are for version 5.10 so
I am running into the stuff in the manuals and tutorials that do not exist in 5.8.

As a starting project to learn the language, I want to execute an AIX
command and be able to read the output of the command in the script.

EXEC doesn't work, because the program ends at the EXEC statement.

SYSTEM does not appear to be available at the 5.8.2 level.

I tried what usually works in other scripting languages of just
putting the command in quotes. Putting "ls" in the script actually
executes the command, and sends the output to the terminal. I want the
output in a file, so I tried "ls > out" and I get an error (shown
below).

I also tried to OPEN, PRINT then CLOSE a file, but the OPEN appears to
fail as if the function is not recignized, and no form of the OPEN
statement seems to work. I have included the script and results below.

This seems like it should be simple, but something escapes me.

Thanks,
Neal

Script:

#/usr/bin/env perl -w
        "ls > out";
print "RC = $?";
open OUTFILE, '< out' or die 'problem';
print while <OUTFILE>;
close (OUTFILE);


Results:

test.pl[2]: ls > out:  not found.
RC = 127
test.pl[4]: open:  not found.
test.pl[5]: 0403-057 Syntax error at line 6 : `;' is not expected.

Perl is not running your script, the shell is. This is because the first line of a script has to start with the two characters '#!' in order for the system to recognise it as a script.

Also:

        "ls > out";

is just a string in void context and does not do anything and OUTFILE is a filehandle opened for input.



John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to