Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Using system command not able to run though the script

by haukex (Archbishop)
on Sep 07, 2016 at 06:41 UTC ( [id://1171293]=note: print w/replies, xml ) Need Help??


in reply to Using system command not able to run though the script

Hi chopraa,

Please use <code> tags to format your post, see e.g. How do I post a question effectively?

When you write:

system("simple_pin_$thost.pl $thost | findstr \n "2016 TTL timed" >> + ping_$thost.txt" );

The quotes after findstr are ending the Perl string, and Perl expects to see an operator there. Escape them with \, or use a different quoting construct:

system("simple_pin_$thost.pl $thost | findstr \n \"2016 TTL timed\" +>> ping_$thost.txt" ); system(qq{simple_pin_$thost.pl $thost | findstr \n "2016 TTL timed" +>> ping_$thost.txt});

See also Quote Like Operators.

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: Using system command not able to run though the script
by chopraa (Initiate) on Sep 08, 2016 at 06:05 UTC
    Using command in scripts still getting the error message . system(qq{simple_pin_$thost.pl $thost | findstr \n "2016 TTL timed" >> ping_$thost.txt}); #system("simple_pin_$thost.pl $thost | findstr \n \"2016 TTL timed\" >> ping_$thost.txt" ); ERROR Message : FINDSTR: Bad command line -Ajay

      Hi chopraa,

      When you write "... \n ...", that is interpolated and produces a newline character in the string. If you want to send the literal string \n to the shell, then in your Perl string you have to escape the backslash and write "... \\n ..." or qq{... \\n ...}. However, NetWallah has a good point, perhaps you meant /n?

      Hope this helps,
      -- Hauke D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found