Re: Can I Set Process Name?

2003-07-08 Thread Drew Tomlinson
- Original Message - 
From: "Daniel Bye" <[EMAIL PROTECTED]>
To: "FreeBSD Questions" <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 9:52 AM

> On Tue, Jul 08, 2003 at 09:11:20AM -0700, Drew Tomlinson wrote:
> > Thanks for the tutorial.  I'm going to drop this as it's not that
> > important.  I can always figure out which one is webmin as it is
> > listening on port 1 and I can see it in the sockstat output.  I
> just
> > thought if I could change the name listed in ps, then I wouldn't
have
> to
> > take the extra step to identify it.
>
> Know what you mean ;-)
>
> Try using the `w' flag to ps:
>
>  ps axfrww | grep webmin
>
> That should do it.

Yes, that works!  Thanks.  In reading the ps man page to learn what
those options are, I see there's LOTS of info to get from the ps
command.

Drew


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Can I Set Process Name?

2003-07-08 Thread Daniel Bye
On Tue, Jul 08, 2003 at 09:11:20AM -0700, Drew Tomlinson wrote:
> Thanks for the tutorial.  I'm going to drop this as it's not that
> important.  I can always figure out which one is webmin as it is
> listening on port 1 and I can see it in the sockstat output.  I just
> thought if I could change the name listed in ps, then I wouldn't have to
> take the extra step to identify it.

Know what you mean ;-)

Try using the `w' flag to ps:

 ps axfrww | grep webmin

That should do it.

Dan

-- 
Daniel Bye

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
 _
  ASCII ribbon campaign ( )
 - against HTML, vCards and  X
- proprietary attachments in e-mail / \


pgp0.pgp
Description: PGP signature


Re: Can I Set Process Name?

2003-07-08 Thread Drew Tomlinson
- Original Message - 
From: "Daniel Bye" <[EMAIL PROTECTED]>
To: "FreeBSD Questions" <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 9:00 AM
Subject: Re: Can I Set Process Name?

> > On Tue, Jul 08, 2003 at 08:43:12AM -0700, Drew Tomlinson wrote:
> > > - Original Message - 
> > From: "Daniel Bye" <[EMAIL PROTECTED]>
> > To: "FreeBSD Questions" <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 08, 2003 8:29 AM
> >
> > On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> > > >
> > > > $0='webmin';
> >  ^
> > > >
> > > > However when starting the program it dies with the following
> > message:
> > > >
> > > > Is there something really easy I'm missing?  If it's complicated
> I'm
> > > > going to forget it as it's not that important.
> >
> > > Yes - a `;' at the end of the line  ;-)
> >
> > Thanks.  That removed the error but failed to change the process
name.
> > I looked at the code a little more.  I'm not experienced in this but
> it
> > seems to me that the 'package miniserv;' line calls a precompiled
> > program?  Here's the beginning of the script:
>
> No - in Perl, a "package" is a namespace - an abstract storage space.
> It
> helps keep a module's (i.e. package's) variables etc logically
separate
> from
> those of other packages.  It prevents collisions in variable names,
data
> structures, etc.
>
> The variable $0 contains, by default, the name of the file containing
> the
> currently running script.
>
> >
> > #!/usr/bin/perl
> > # A very simple perl web server used by Webmin
> >
> > $0='webmin';
> >
> > # Require basic libraries
> > package miniserv;<-- This is just declaring that the following
> code is
>in the "miniserv" package.
> > use Socket;
> > use POSIX;
> >
> > Then a little farther in the script, I see this code:
> >
> > # Get miniserv's perl path and location
> > $miniserv_path = $0;
> > open(SOURCE, $miniserv_path);
> >  =~ /^#!(\S+)/; $perl_path = $1;
> > close(SOURCE);
> > @miniserv_argv = @ARGV;
> >
> > So I suspect the process name gets set in this somewhere?
>
> As you have poked $0 before it gets this far, no - $0 contains the
value
> you
> set above.  Which might, in itself, cause problems later in the
script.
> Without reviewing it, I couldn't tell you.

Thanks for the tutorial.  I'm going to drop this as it's not that
important.  I can always figure out which one is webmin as it is
listening on port 1 and I can see it in the sockstat output.  I just
thought if I could change the name listed in ps, then I wouldn't have to
take the extra step to identify it.

Thanks,

Drew

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Can I Set Process Name?

2003-07-08 Thread Daniel Bye
On Tue, Jul 08, 2003 at 08:43:12AM -0700, Drew Tomlinson wrote:
> - Original Message - 
> From: "Daniel Bye" <[EMAIL PROTECTED]>
> To: "FreeBSD Questions" <[EMAIL PROTECTED]>
> Sent: Tuesday, July 08, 2003 8:29 AM
> 
> On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> > >
> > > $0='webmin';
>  ^
> > >
> > > However when starting the program it dies with the following
> message:
> > >
> > > Is there something really easy I'm missing?  If it's complicated I'm
> > > going to forget it as it's not that important.
> 
> > Yes - a `;' at the end of the line  ;-)
> 
> Thanks.  That removed the error but failed to change the process name.
> I looked at the code a little more.  I'm not experienced in this but it
> seems to me that the 'package miniserv;' line calls a precompiled
> program?  Here's the beginning of the script:

No - in Perl, a "package" is a namespace - an abstract storage space.  It
helps keep a module's (i.e. package's) variables etc logically separate from
those of other packages.  It prevents collisions in variable names, data
structures, etc.

The variable $0 contains, by default, the name of the file containing the
currently running script.  

> 
> #!/usr/bin/perl
> # A very simple perl web server used by Webmin
> 
> $0='webmin';
> 
> # Require basic libraries
> package miniserv;<-- This is just declaring that the following code is
   in the "miniserv" package.
> use Socket;
> use POSIX;
> 
> Then a little farther in the script, I see this code:
> 
> # Get miniserv's perl path and location
> $miniserv_path = $0;
> open(SOURCE, $miniserv_path);
>  =~ /^#!(\S+)/; $perl_path = $1;
> close(SOURCE);
> @miniserv_argv = @ARGV;
> 
> So I suspect the process name gets set in this somewhere?

As you have poked $0 before it gets this far, no - $0 contains the value you
set above.  Which might, in itself, cause problems later in the script.
Without reviewing it, I couldn't tell you.

Dan

-- 
Daniel Bye

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
 _
  ASCII ribbon campaign ( )
 - against HTML, vCards and  X
- proprietary attachments in e-mail / \


pgp0.pgp
Description: PGP signature


Re: Can I Set Process Name?

2003-07-08 Thread Drew Tomlinson
- Original Message - 
From: "Daniel Bye" <[EMAIL PROTECTED]>
To: "FreeBSD Questions" <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 8:29 AM

On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> >
> > $0='webmin';
 ^
> >
> > However when starting the program it dies with the following
message:
> >
> > Is there something really easy I'm missing?  If it's complicated I'm
> > going to forget it as it's not that important.

> Yes - a `;' at the end of the line  ;-)

Thanks.  That removed the error but failed to change the process name.
I looked at the code a little more.  I'm not experienced in this but it
seems to me that the 'package miniserv;' line calls a precompiled
program?  Here's the beginning of the script:

#!/usr/bin/perl
# A very simple perl web server used by Webmin

$0='webmin';

# Require basic libraries
package miniserv;
use Socket;
use POSIX;

Then a little farther in the script, I see this code:

# Get miniserv's perl path and location
$miniserv_path = $0;
open(SOURCE, $miniserv_path);
 =~ /^#!(\S+)/; $perl_path = $1;
close(SOURCE);
@miniserv_argv = @ARGV;

So I suspect the process name gets set in this somewhere?

Thanks,

Drew



___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Can I Set Process Name?

2003-07-08 Thread Tobias Grosser
On Tue, 8 Jul 2003 08:26:45 -0700
"Drew Tomlinson" <[EMAIL PROTECTED]> wrote:

> Is there something really easy I'm missing?  If it's complicated I'm

Try to write a semicolon at the end of the line.


#!/usr/bin/perl
# A very simple perl web server used by Webmin

$0='webmin';

# Require basic libraries
package miniserv;
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Can I Set Process Name?

2003-07-08 Thread Daniel Bye
On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> 
> $0='webmin';
 ^
> 
> However when starting the program it dies with the following message:
> 
> Is there something really easy I'm missing?  If it's complicated I'm
> going to forget it as it's not that important.

Yes - a `;' at the end of the line  ;-)

Dan

-- 
Daniel Bye

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
 _
  ASCII ribbon campaign ( )
 - against HTML, vCards and  X
- proprietary attachments in e-mail / \


pgp0.pgp
Description: PGP signature


Re: Can I Set Process Name?

2003-07-08 Thread Drew Tomlinson
- Original Message - 
From: "Simon Barner" <[EMAIL PROTECTED]>
To: "Rob" <[EMAIL PROTECTED]>
Cc: "Drew Tomlinson" <[EMAIL PROTECTED]>; "FreeBSD Questions"
<[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 8:14 AM

> > setproctitle(3) - but I don't know how you would call it from perl.

> You can do it by altering the $0 variable:

> #!/usr/bin/perl -w
> use strict;

> $0='Will it work?';

> sleep (10);

> A ps | grep 'Will' gives me:

> 2551  p3  SN 0:00.02 Will it work? (perl)

Thank you both for your answers.  I'm not much of a scripter but I tried
your suggestion with the webmin script.  I found that the actual file is
/usr/local/lib/webmin/miniserv.pl and edited the beginning of the file
as such:

#!/usr/bin/perl
# A very simple perl web server used by Webmin

$0='webmin'

# Require basic libraries
package miniserv;

However when starting the program it dies with the following message:

syntax error at /usr/local/lib/webmin/miniserv.pl line 7, near "package
miniserv"
BEGIN not safe after errors--compilation aborted at
/usr/local/lib/webmin/miniserv.pl line 8.

Is there something really easy I'm missing?  If it's complicated I'm
going to forget it as it's not that important.

Thanks,

Drew


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Can I Set Process Name?

2003-07-08 Thread Simon Barner
> setproctitle(3) - but I don't know how you would call it from perl.

You can do it by altering the $0 variable:

#!/usr/bin/perl -w
use strict;

$0='Will it work?';

sleep (10);

A ps | grep 'Will' gives me:

 2551  p3  SN 0:00.02 Will it work? (perl)
 
Regards,
 Simon


signature.asc
Description: Digital signature


Re: Can I Set Process Name?

2003-07-08 Thread Rob
setproctitle(3) - but I don't know how you would call it from perl.

- Original Message -
From: "Drew Tomlinson" <[EMAIL PROTECTED]>
To: "FreeBSD Questions" <[EMAIL PROTECTED]>
Sent: Wednesday, July 09, 2003 12:09 AM
Subject: Can I Set Process Name?


> Is there a way to either change the name of a running process or start
> the process with a name of my choosing?  On my system, I am running
> webmin and spamd.  Both processes show in ps -acux output as "perl".
>
> blacklamb# ps -acux | grep perl
> root 22476  0.0  2.9  6760 5576  ??  Ss   Sat11AM   0:06.30
perl
> root 33725  0.0 11.0 21604 21196  ??  Ss9:07PM   0:03.11
> perl
>
> Is there a way to make the webmin process name "webmin" and the spamd
> process "spamd"?  I'm willing to read but have no idea where to start
so
> please nudge me in the right direction.
>
> Thanks,
>
> Drew
>
> ___
> [EMAIL PROTECTED] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
"[EMAIL PROTECTED]"
>

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"