Help - Search - Member List - Calendar
Full Version: PID of a perl script
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
Mads N. Vestergaard
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey Everybody,

Just a simple question.
How do I get the PID of my running perl script.
I would like to have it in my perlscript so I can write it to a .pid file.

Thanks guys,

Mads

- --
Mads N. Vestergaard - http://rwxr-xr-x.dk
Interested in Open Source, and web application development
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC0t7q7WOaPMd53OMRAuXRAJ9ORCTXe9xkuuvIumtsPyHnLAqJSgCcDTon
UaR3iFTEnE0igQuDBfdpFmY=
=Gqt+
-----END PGP SIGNATURE-----

Errin M HMMA/Information Technol
Mads N. Vestergaard wrote:
QUOTE
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey Everybody,


Hi there!

QUOTE
Just a simple question.
How do I get the PID of my running perl script.

Check out the doc 'perlvar'.

# perldoc perlvar

Then, do a search for 'PID'.

It's in there.


QUOTE
Thanks guys,

Mads


Always happy to help!
Always check those perldocs first!!

--Errin

Wiggins d'Anconia
Mads N. Vestergaard wrote:
QUOTE
Hey Everybody,

Just a simple question.
How do I get the PID of my running perl script.
I would like to have it in my perlscript so I can write it to a .pid file.

Thanks guys,

Mads


$$ is a special variable that holds what you are after.

perldoc perlvar

For other special variables.

http://danconia.org

Jay Savage
On 7/11/05, Mads N. Vestergaard <[Email Removed]> wrote:
QUOTE
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey Everybody,

Just a simple question.
How do I get the PID of my running perl script.
I would like to have it in my perlscript so I can write it to a .pid file..

Thanks guys,

Mads

- --
Mads N. Vestergaard - http://rwxr-xr-x.dk
Interested in Open Source, and web application development

It's stored in the special variable $$. See perlvar for details.

You might also want to check out the cpan File::Pid module, which
automates pid file management.

-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com

Mads N. Vestergaard
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey again,

Thanks for the replies.
I also got it ton work, but I still have on question. Too get the actual
PID i need to say $$+1, do you guys have any idea why I should do that.
In perlvar it also says $PID should return the pid. It doesn't work for
me, cann I be doing something wrong?

Thanks

Jay Savage wrote:
| On 7/11/05, Mads N. Vestergaard <[Email Removed]> wrote:
|
|>-----BEGIN PGP SIGNED MESSAGE-----
|>Hash: SHA1
|>
|>Hey Everybody,
|>
|>Just a simple question.
|>How do I get the PID of my running perl script.
|>I would like to have it in my perlscript so I can write it to a .pid file.
|>
|>Thanks guys,
|>
|>Mads
|>
|>- --
|>Mads N. Vestergaard - http://rwxr-xr-x.dk
|>Interested in Open Source, and web application development
|
|
| It's stored in the special variable $$. See perlvar for details.
|
| You might also want to check out the cpan File::Pid module, which
| automates pid file management.
|
| -- jay
| --------------------------------------------------
| This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
| private and confidential
|
| daggerquill [at] gmail [dot] com
|

- --
Mads N. Vestergaard - http://rwxr-xr-x.dk
Interested in Open Source, and web application development
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1E4c7WOaPMd53OMRAhQnAJ9M/dJpdnQeQ9wvH0hs0I5lHfctrwCgizHN
FQIYmJXl/l94d9XZOKc6flg=
=+LMt
-----END PGP SIGNATURE-----

Wiggins d'Anconia
Please bottom post...

Mads N. Vestergaard wrote:
QUOTE
Hey again,

Thanks for the replies.
I also got it ton work, but I still have on question. Too get the actual
PID i need to say $$+1, do you guys have any idea why I should do that.

Without seeing some code no, though if there is any forking going on
then that might explain it. What system/OS?

QUOTE
In perlvar it also says $PID should return the pid. It doesn't work for
me, cann I be doing something wrong?


First couple of sentences of perldoc perlvar indicate:

"Nevertheless, if you wish to use long variable names, you need only say

use English;

at the top of your program. This aliases all the short names to the long
names in the current package." Note IIRC there is a performance hit at
least at startup.

QUOTE
Thanks


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.