Yep, Rob, you're right on the money:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # head -1 webhits.pl 
weatherbug.pl|hexdump -c
0000000   =   =   >       w   e   b   h   i   t   s   .   p   l       <
0000010   =   =  \n   #   !   /   u   s   r   /   l   o   c   a   l   /
0000020   b   i   n   /   p   e   r   l  \r  \n  \n   =   =   >       w
0000030   e   a   t   h   e   r   b   u   g   .   p   l       <   =   =
0000040  \n   #   !   /   u   s   r   /   l   o   c   a   l   /   b   i
0000050   n   /   p   e   r   l      \n                                
0000058
centernet:/usr/local/httpd/htdocs/cacti8/scripts # vi webhits.pl 

I used this one-liner to delete the ^Ms:
perl -pi.dos -e 's/\cM$//' webhits.pl

Now, webhits works fine:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # ./webhits.pl
8088centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

Thanks, again, Rob, for your help.

-Kevin

>>> "Hanson, Rob" <[EMAIL PROTECTED]> 08/12/03 11:10AM >>>
> The she-bang line seems correct
> I'm stumped. Can anyone point out the
> boneheaded mistake I'm making?

If I had to guess, I think the problem is an invalid unprintable character
in the shebang line (I think a non-Unix newline).  The bash shell seems to
include the non-printable char as part of the executable name.

Anyway... try creating a new file, type the shebang line with a blank line,
then copy the rest of the file in.  This usually does the trick.  There is
also a utility called fixnl that I use that seems to work too.

Rob

-----Original Message-----
From: KEVIN ZEMBOWER [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 12, 2003 10:56 AM
To: [EMAIL PROTECTED] 
Subject: Can run through perl, but not alone?


I feel so stupid, but I and a co-worker have been staring at this for two
hours, with no progress.

I'm trying to run some perl scripts which came with the system Cacti. One is
webhits.pl:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # cat webhits.pl
#!/usr/local/bin/perl

if ($ARGV[0] eq "") {
        $log_path = "/var/log/httpd/access_log";
}else{
        $log_path = $ARGV[0];
}

$webhits = `wc -l $log_path`;
$webhits =~ s/[\s]*([0-9]+).*//;

print $1;

centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

I get this error if I run it alone, but not through perl:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # ./webhits.pl
bash: ./webhits.pl: No such file or directory
centernet:/usr/local/httpd/htdocs/cacti8/scripts # perl ./webhits.pl
7907centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

(The '7907' is the output.) It doesn't matter if I use the full path to the
file or not. A similar script in the same directory runs fine without
invoking perl on the command line:
7907centernet:/usr/local/httpd/htdocs/cacti8/scripts # cat weatherbug.pl
#!/usr/local/bin/perl 

$output = `/bin/bash -c 'wget --quiet -O -
\"http:\/\/wisapidata.weatherbug.com\/WxDataISAPI\/WxDataISAPI.dll?Magic=109
91&RegNum=3647055&ZipCode=17241&StationID=NWVLL&Units=0&Version=2.7&Fore=1&t
=1015084854\/"'`; 

$output =~ s/[%]|[°]|[n]|[s]|[r]|[f]//gi; 

@weather = split(/\|/, $output); 

# docs 
# [0] - ID? 
# [1] - Current Time 
# [2] - Current Date 
# [3] - Current Temperature 
# [5] - Wind Speed (MPH) 
# [7] - Gust Wind Speed (MPH) 
# [10] - Barometer (Moisture) 
# [11] - Humidity (%) 
# [12] - High Tempurature 
# [13] - Low Temperature 
# [14] - Dew Point 
# [15] - Wind Chill 

print "current_temp:" . $weather[3] . " wind_speed:" . $weather[5] . "
barometer:" . $weather[10] . " humidity:" . 
        $weather[11] . " high_temp:" . $weather[12] . " low_temp:" .
$weather[13] . " dew_point_temp:" . 
        $weather[14] . " wind_chill_temp:" . $weather[15];
centernet:/usr/local/httpd/htdocs/cacti8/scripts # ./weatherbug.pl
current_temp:77 wind_speed:0 barometer:30.12 humidity:72 high_temp:78
low_temp:64 dew_point_temp:68
wind_chill_temp:80centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

The she-bang line seems correct, and in any case, it's the same between the
two files:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # which perl
/usr/local/bin/perl
centernet:/usr/local/httpd/htdocs/cacti8/scripts # head -1 webhits.pl
weatherbug.pl
==> webhits.pl <==
#!/usr/local/bin/perl

==> weatherbug.pl <==
#!/usr/local/bin/perl 
centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

There don't seem to be any invisible characters in the name, and the
permissions seem fine:
centernet:/usr/local/httpd/htdocs/cacti8/scripts # ls -lb w*
-rwxr-xr-x    1 cactiuse webadmin      899 Aug 12 09:54 weatherbug.pl
-rwxr-xr-x    1 cactiuse webadmin      791 Jun 12 16:06 weatherbug.pl.orig
-rwxr-xr-x    1 cactiuse webadmin      208 Aug 12 10:28 webhits.pl
centernet:/usr/local/httpd/htdocs/cacti8/scripts # 

I'm stumped. Can anyone point out the boneheaded mistake I'm making?

Thanks for your help.

-Kevin Zembower


-----
E. Kevin Zembower
Unix Administrator
Johns Hopkins University/Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139

--
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to