(hopefully) simple perl question...
Is there a built in command, or shell command to retrieve the process name from a pid? The best I could come up with is slurping the stuff from /proc/cmdline or something like ps|cut, but it seems to me there is probably a better way I am ignorant of. Thanks! Jonathan -- [EMAIL PROTECTED] GPG public key available from http://www.jamdata.net/~jjlupa/gpg.asc pgpMvkrEdfWIR.pgp Description: PGP signature
Re: (hopefully) simple perl question...
On Mon, 28 Feb 2000, Jonathan Lupa wrote: Is there a built in command, or shell command to retrieve the process name from a pid? ps ax | awk '$1 == pid {print $5}' There's no builtin command to do this. I don't know if Perl can do it or not. I doubt it, though. The best I could come up with is slurping the stuff from /proc/cmdline or something like ps|cut, but it seems to me there is probably a better way I am ignorant of. /proc/pid/cmdline won't work on anything except linux; you should use ps.
Re: (hopefully) simple perl question...
[EMAIL PROTECTED] (William T Wilson) wrote: On Mon, 28 Feb 2000, Jonathan Lupa wrote: Is there a built in command, or shell command to retrieve the process name from a pid? ps ax | awk '$1 == pid {print $5}' Or indeed 'ps -o%c h -p pid'. This will probably break on other Unices (and older versions of ps, for that matter), but this is debian-user, right? :) -- Colin Watson [EMAIL PROTECTED]
Re: (hopefully) simple perl question...
On Tue, Feb 29, 2000 at 03:42:20AM +, Colin Watson wrote: [EMAIL PROTECTED] (William T Wilson) wrote: ps ax | awk '$1 == pid {print $5}' Or indeed 'ps -o%c h -p pid'. Thanks guys! :) -- [EMAIL PROTECTED] GPG public key available from http://www.jamdata.net/~jjlupa/gpg.asc pgp5px2HKScTJ.pgp Description: PGP signature
Re: (hopefully) simple perl question...
Jonathan Lupa wrote: Is there a built in command, or shell command to retrieve the process name from a pid? The best I could come up with is slurping the stuff from /proc/cmdline or something like ps|cut, but it seems to me there is probably a better way I am ignorant of. I wonder if the Proc::ProcessTable module, available at CPAN, wouldn't do this for you?
simple perl question
In a perl script i need to load a variable ($CurrentTime) with the systems current time. Normally I would consult with my reference books but am not able to get to them. I find myself using them when I need to work in perl which is not very often... I'm looking for time_stamp something like 07/17/98 14:42:09 for a requirement that has surfaced. I thought maybe something like: $CurrentTime=exec`date +%D %T`; print $CurrentTime; Hope that jibberish above made sense :-/ Oh yeah... The perl version is rather old (v. 4.0.1.8). upgrading is not an option for those solutions requiring version 5.x. Thanks for any help. Please reply to [EMAIL PROTECTED] and the group... -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null
Re: simple perl question
I thought maybe something like: $CurrentTime=exec`date +%D %T`; print $CurrentTime; $CurrentTime=localtime(time); Alex Y. -- _ _( )_ ( (o___ +---+ | _ 7 |Alexander Yukhimets| \()| http://pages.nyu.edu/~aqy6633/ | / \ \ +---+ -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null
RE: simple perl question
dave oswald [EMAIL PROTECTED] writes: Normally I would consult with my reference books but am not able to get to them. Or you could just try it! :) I thought maybe something like: $CurrentTime=exec`date +%D %T`; print $CurrentTime; % perl -e '$CurrentTime = `date +%D %T`; print $CurrentTime' 07/17/98 22:10:42 -Jeff * | Jeff Schreiber | System administrators are, of course, | | aka - Spectre | incorruptible. You can offer me any | | [EMAIL PROTECTED] | amount of money. And you can believe | | | me, because I'm always right, and I| | | never lie. | | | (Paul Sand - [EMAIL PROTECTED]) | * -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null