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:
need another set of eyes on my perl script

 

First page Previous page 1 2 Next page Last page  View All


FishMonger
Veteran / Moderator

May 4, 2009, 4:47 PM

Post #26 of 30 (1846 views)
Re: [richsark] need another set of eyes on my perl script [In reply to] Can't Post

Your getobjectlst.exe program is sending "Error 48: This subnet does not exist." to STDERR.

When you use backticks, your @dnsoptions array is populated with the STDOUT stream and doesn't see the STDERR stream. You need to either redirect STDERR to STDOUT or use one of Perl's other methods for executing the external command that reads STDERR.

Using the IPC::Open3 module would be best, but at your current level of understanding, that method would confuse you more than you are now.

This redirects STDERR to STDOUT:

Code
my @dnsoptions = `./getobjectlst.exe -u x-p x-o Rich -a $subnet 2>&1`;



richsark
User

May 4, 2009, 5:49 PM

Post #27 of 30 (1843 views)
Re: [FishMonger] need another set of eyes on my perl script [In reply to] Can't Post

OK FishMOnger, I uderstand completly.

It ran, it took longer this time as I beleive it was checking those Error 48's

But...Blush I got these messages now

$ perl fish3.pl
Checking 10.0.0.0/8
Checking 146.149.0.0/16
Checking 161.16.0.0/16
Checking 161.56.0.0/16
Checking 162.2.0.0/16
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file


(This post was edited by richsark on May 4, 2009, 5:54 PM)


FishMonger
Veteran / Moderator

May 4, 2009, 6:52 PM

Post #28 of 30 (1828 views)
Re: [richsark] need another set of eyes on my perl script [In reply to] Can't Post


In Reply To
OK FishMOnger, I uderstand completly.

It ran, it took longer this time as I beleive it was checking those Error 48's

But...Blush I got these messages now

$ perl fish3.pl
Checking 10.0.0.0/8
Checking 146.149.0.0/16
Checking 161.16.0.0/16
Checking 161.56.0.0/16
Checking 162.2.0.0/16
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file


Those are coming from the shell while executing your command in the backticks. You might want to refer that question to a forum that is dedicated to your external commands.


richsark
User

May 4, 2009, 7:02 PM

Post #29 of 30 (1826 views)
Re: [FishMonger] need another set of eyes on my perl script [In reply to] Can't Post

HI,

So we cant fix this and close this out?

Does this mean the code is all wrong since we are using back-ticks?


richsark
User

May 5, 2009, 6:54 AM

Post #30 of 30 (1815 views)
Re: [richsark] need another set of eyes on my perl script [In reply to] Can't Post

Hi,

How can I format the results, seems like its doing a carriage return.

Now it looks like this:

Subnet,Static,DHCP,Unused

10.0.0.0/8
,37,0,217
146.149.0.0/16
,174,0,39314

Can it be formated

Subnet,Static,DHCP,Unused
10.0.0.0/8,37,0,217

I tried to play with the line

printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};

I tried this:
printf $log "%s,%d,%d,%d,%d\n", $subnet, $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};

And:

printf $log "%s,%d,%d,%d\n", $subnet, $subnet\n $counts{Static}, $counts{DHCP}, $counts{Unused};

Any thoughts?




First page Previous page 1 2 Next page Last page  View All
 
 


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

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