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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
path in perl?


mike robb

Sep 24, 2000, 11:06 AM

Post #1 of 2 (201 views)
path in perl? Can't Post

I have the following program that i have set up to run under cron - to keep the program alive.

i was trying to use the INC array to get the path correct.

i'm trying the cd as a dual command split by the ";" but i thought there was a way to set the path of the perl file so that all commands would be relative to that path.
(which works...)


any ideas?


unshift(@INC, "/home/beaker/counter");

$cmd="/bin/ps -elf | grep -v grep | grep $port | grep $proc_name";
open(CMD,"$cmd |") | | die "Can not issue acommand: $cmd:$!\n";
while(<CMD> )
$_=~s/ / /g; # remove all extra spaces
($f,$e,$uid,$pid) = split(' ',$_);
$cmd = substr($x,64,400);
#print "uid=$uid pid=$pid cmd=$cmd\n";
if ($found!=1)
#print "need to start process\n";
$cmd="cd /home/beaker/counter/;/usr/bin/java Server 6234 &";
open(CMD,"$cmd |") &#0124; &#0124; die "Can not issue restart command: $cmd:$!\n";
#print "process is going fine.\n";



User / Moderator

Sep 24, 2000, 3:52 PM

Post #2 of 2 (201 views)
Re: path in perl? [In reply to] Can't Post

Setting your path(s) is something that needs be done via the PATH key of %ENV ( ie, $ENV{'PATH'} ), which should contain a string of all the paths you want to search for programs in seperated by colons.


<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

local $ENV{'PATH'} = '/path/to/dir/1:/path/to/dir/2:/etc/etc';</pre><HR></BLOCKQUOTE>

... or a little more readable ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

local $ENV{'PATH'} = join( ":" => qw(
) );</pre><HR></BLOCKQUOTE>


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

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