CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
system usage help required

 



vegirs
New User

Feb 5, 2011, 8:39 PM

Post #1 of 7 (1340 views)
system usage help required Can't Post

Hi Friends,
I am trying to execute an external command using my perl script
command to pass --> perl conn_status.pl 192.168.0.1 | find /I "$String"

I tried using system, but not successful. Please assist

error msg -- string found where operator expected at test.pl line 30, near "$String""".
(missing operator before "" ?)


shawnhcorey
Enthusiast


Feb 6, 2011, 6:20 AM

Post #2 of 7 (1324 views)
Re: [vegirs] system usage help required [In reply to] Can't Post

How about showing the code? I think you're trying to use a double quote inside a double-quoted string.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


rovf
Veteran

Feb 7, 2011, 5:19 AM

Post #3 of 7 (1292 views)
Re: [vegirs] system usage help required [In reply to] Can't Post

From your posting, I can say that the error is likely in line 30 of your code. I really want to point it out more in detail, but my paranormal abilities went a bit rusty recently, so although I'm trying hard, I can't see your code clearly ;-)

Or, maybe you've just forgotten to attach your code?

Ronald


vegirs
New User

Feb 8, 2011, 10:19 PM

Post #4 of 7 (1279 views)
Re: [vegirs] system usage help required [In reply to] Can't Post

 
Yes u r correct and I missed to update the script, I have given part of the script where I have an issue.
I have an issue in system syntax. My basic intenion was to call another perl script (conn_status.pl and use double quotes for find

open(MYINPUTFILE1, "<clariion.host");
while(<MYINPUTFILE1>)
{
my($text) = $_;
chomp($text);
my($array_serial, $IP_SPA, $IP_SPB) = split(/:/,$text);
if ($array_serial == $arrayserial) {
print "$array_serial \t $IP_SPA \t $IP_SPB \n\n";
system "perl Conn_Status.pl $IP_SPA | find /I "$target_array"";
print "\n\n"
         }


BillKSmith
Veteran

Feb 9, 2011, 6:40 AM

Post #5 of 7 (1272 views)
Re: [vegirs] system usage help required [In reply to] Can't Post

Consider doing the whole job in perl. Check out the module File::Find. It traverses a directory tree much the same way your system find routine does. The required call back routine would be nearly trivial.
Good Luck,
Bill


vegirs
New User

Feb 14, 2011, 9:52 AM

Post #6 of 7 (1232 views)
Re: [BillKSmith] system usage help required [In reply to] Can't Post

finally got my desired output using print.

print (`my command`);

Thanks all for your support and suggestions


rovf
Veteran

Feb 15, 2011, 5:52 AM

Post #7 of 7 (1221 views)
Re: [vegirs] system usage help required [In reply to] Can't Post

Isn't it a bit pointless to collect the stdout of an external program, and then print it to stdout again? You could get the same effect more efficient by


Code
use File::Spec::Functions qw(devnull); 
...
system("my command 2>".devnull);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives