Ask a Question related to PERL Beginners, Design and Development.
-
Vema Venkata #1
pls do reply
How do i get the process id into a variable ?
can any one help
$pid = qx(ps -f|grep srvtst26);
print "Server Started : $pid \n
Vema Venkata Guest
-
reply
What kind of problems ? Please explain with error messages, etc. Would be nice also to give some details of your system (Operating System) Ray -
Why do I get zero sized reply???
Why after running the following script do I get zero sized reply?? It seems to hang when I access the $link_id (when comparing it, negating,... -
do not reply
Don't tell me what to do! "Dave Slater" <elninia@nospam.adelphia.net> wrote in message news:uIXXa.9708$jg.2578237@news1.news.adelphia.net... -
reply for your message
Hi, In message "your message" on 03/08/26, Mathieu Bouchard <matju@sympatico.ca> writes: |From: matz@ruby-lang.org (Yukihiro Matsumoto)... -
jupiters reply
Your welcome Jim. It is functioning normally. -- Jupiter Jones An easier way to read newsgroup messages:... -
Matthew Harrison #2
Re: pls do reply
there is a var with it already set:
perldoc perlvar
see $PID or $$
On Tue, Sep 09, 2003 at 10:07:43PM +1000, Vema Venkata wrote:--> How do i get the process id into a variable ?
> can any one help
>
>
> $pid = qx(ps -f|grep srvtst26);
> print "Server Started : $pid \n
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
[email]matth@3d-computers.co.uk[/email]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (OpenBSD)
iD8DBQE/XcQbmbMTrp/jhicRAsyDAJwOBlSQf8fpBTqotiaz+7Aqh/rJRgCfW29T
DGKtIGhK5TUZSBeRFitTAEg=
=7srf
-----END PGP SIGNATURE-----
Matthew Harrison Guest
-
Gavin Laking #3
Re: process id (pls do reply)
On Tue, 9 Sep 2003 22:07:43 +1000
[email]venkatsb@anz.com[/email] (Vema Venkata) wrote:
Try giving a description of your problem in the subject line it helps.> How do i get the process id into a variable ?
> can any one help
>
> $pid = qx(ps -f|grep srvtst26);
> print "Server Started : $pid \n
The process id is stored in '$$'. There is no need to jump through hoops
to get it.
Cheers,
GL
--
Gavin Laking - Web Development Daemon
[url]http://www.gavinlaking.co.uk/[/url]
--
Gavin Laking Guest
-
Sudarshan Raghavan #4
Re: pls do reply
Vema Venkata wrote:
Process Id of what?>How do i get the process id into a variable ?
>can any one help
>
$$ will contain the process id your current perl script. perldoc perlvar
If you want to get the process id based on the command name,
Proc::ProcessTable will interest you.
>
>
>$pid = qx(ps -f|grep srvtst26);
> print "Server Started : $pid \n
>
>
>Sudarshan Raghavan Guest
-
Vema Venkata #5
RE: pls do reply
#!/proj/ahd02/CAisd/ActivePerl-5.6.0.618/bin/perl
#/usr/local/bin/perl
use POSIX qw(strftime);
$now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
$xapipgm = "/proj/ahd02/CAisd/site/mods/scripts/srvtst26.pl";
$pid = qx(pgrep -f srvtst26);
if ($pid =! 0){
print "AHD XAPI SERver Running with Process ID '$pid' On $now_string\n" ;
}
else{
$pid = `ps-f|grep $srvtst26`;
print "Server Started : $pid \n";
open (F, ">> /proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init.log") || die "OS Error was $! \n";
print F "AHDXAPI Server is now started running '$pid' $now_string";
close F;
}
In the above pgm
$pid = qx(pgrep -f srvtst26); #here it check if the process is running say if it is running it writes to a log file
else
$pid = `ps-f|grep $srvtst26`;
here in the above command it has to grep the process id and return to a variable $pid and write it to a log file
Vema Venkata Guest
-
Jeff 'Japhy' Pinyan #6
Re: pls do reply
On Sep 9, Vema Venkata said:
qx() returns the output. You want to use open():>How do i get the process id into a variable ?
>
>$pid = qx(ps -f|grep srvtst26);
> print "Server Started : $pid \n
$pid = open PS, "ps -f | grep srvtst26 |"
or die "'ps -f | grep srvtst26' error: $!";
You can read the output from <PS>.
--
Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Jeff 'Japhy' Pinyan Guest
-
R. Joseph Newton #7
Re: pls do reply
Vema Venkata wrote:
Huh? What is happening here. Your subject line whines for a response, and yet in your code you totally disregard the> #!/proj/ahd02/CAisd/ActivePerl-5.6.0.618/bin/perl
> #/usr/local/bin/perl
>
> use POSIX qw(strftime);
>
> $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
advice that has been consistently offered. You have launched into executable code without taking the effort to
use strict;
use warnings;
...and handle your share of the work by dealing with any errors reported.
Shouldn't you do what you can to help yourself before asking others to help you?
FWIW, I ran your code, and started dealing with the errors. Then I decided that that was your job.
Please turn strict and warnings back on, and then ask about anything not clear to you in the error messages.
Joseph
R. Joseph Newton Guest



Reply With Quote

