Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Error while running PERL in windows

by mpatel1516 (Initiate)
on Apr 12, 2016 at 02:36 UTC ( [id://1160179]=perlquestion: print w/replies, xml ) Need Help??

mpatel1516 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Error while running PERL in windows
by NetWallah (Canon) on Apr 12, 2016 at 05:08 UTC
    It appears that you are trying to run the command 'bpimagelist -A -media -hoursago', and parse the output.

    You need to first "quote" the string, and then understand how perl handles the "\" (backslash) character, which has a special meaning inside a double-quoted string.

    It is very difficult to determine what you are attempting, because you have not used <code> tags., but here is a guess at at one way to achieve what your first command is trying:

    my @MEDIA; chdir 'C:\Program Files\Veritas\Netbackup\bin\admincmd\'; for ( qx{bpimagelist -A -media -hoursago 24} ){ s/\|/ /; my ($Image) = split; }

            This is not an optical illusion, it just looks like one.

Re: Error while running PERL in windows
by Corion (Patriarch) on Apr 12, 2016 at 07:05 UTC
    Backslash found where operator expected at Test.pl line 2, near "Verit +as\"

    So, what have you done to remedy that error in line 2?

    Perl is not Powershell and not cmd.exe. The for command has a different syntax in Perl. See perlsyn.

    You will have to use Perl syntax to write Perl code, this also goes for file paths.

    If you want to read output from a subprocess, you can use backticks (see perlop and readline):

    my $command = "C:\\Program Files\\Veritas\\Netbackup\\bin\\admincmd>bp +imagelist -A -media -hoursago 24>"; for my $line (`$command`) { ... };

      Or just:

      for my $line ( `C:/Program Files/Veritas/Netbackup/bin/admincmd/bpimag +elist -A -media -hoursago 24` ) { ... };

      Which is simpler, and works. Note also:

      1. The change from '>' to '/' between the last element of the path and the command name.
      2. the absence of the '>' at the end of the command.

      Both of which are left-overs from his attempt to convert his original qx<> delimited unix command lines to windows equivalents.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Error while running PERL in windows
by Laurent_R (Canon) on Apr 12, 2016 at 08:09 UTC
    Hi mpatel1516,

    You've been told several times in your earlier thread (Run Perl script in windows) to use <code> and </code> tags for code and data, and <p> and </p> tags for plain paragraphs, in order to make your posts readable, but have so far kept not doing it in your new posts of that same other thread.

    This new thread here is again not doing it. Many monks here will simply not take the pain to try to read your posts if you keep refusing to format them correctly. Please, help us to help you, make your posts legible.

Re: Error while running PERL in windows
by james28909 (Deacon) on Apr 12, 2016 at 04:08 UTC
    Please use code tags <code> </code> around your code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1160179]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found