Re: Long shot but worth a try...

2004-02-26 Thread Sherm Pendley
On Feb 26, 2004, at 11:14 AM, Riccardo Perotti wrote:

Can somebody point me in the right direction and / or contribute an 
idea for
this?
Have a look at the man page for the 'killall' command. In short, it 
signals processes by name, so you don't need to know the PID. You can 
use system() to run it from Perl, like this:

#!/usr/bin/perl

use warnings;
use strict;
system 'killall -KILL pppd';

sherm--



Re: Long shot but worth a try...

2004-02-26 Thread Riccardo Perotti
On 2/26/04 11:24 AM, Sherm Pendley [EMAIL PROTECTED] wrote:

 On Feb 26, 2004, at 11:14 AM, Riccardo Perotti wrote:
 
 Can somebody point me in the right direction and / or contribute an
 idea for
 this?
 
 Have a look at the man page for the 'killall' command. In short, it
 signals processes by name, so you don't need to know the PID. You can
 use system() to run it from Perl, like this:
 
 #!/usr/bin/perl
 
 use warnings;
 use strict;
 
 system 'killall -KILL pppd';
 
 sherm--
 
 
Thanks Sherm! That definitely looks like a step in the right direction.

Now the only problem is that 'pppd' a process owned by root. Should my
script be run as 'root'? That sounds kind of dangerous! ... can it / should
it be done? When at the Terminal I have to 'sudo kill' and the get asked my
password. How would I do a 2 step process from 1 perl script?

Thanks again!


Riccardo



--
mailto:[EMAIL PROTECTED]
http://www.riccardoperotti.com




Re: Long shot but worth a try...

2004-02-26 Thread Joseph Alotta
From the sudo manpage:

   -S  The -S (stdin) option causes sudo to read the password from 
stan-
   dard input instead of the terminal device.

Joe Alotta

On Feb 26, 2004, at 9:48 PM, Riccardo Perotti wrote:

On 2/26/04 11:24 AM, Sherm Pendley [EMAIL PROTECTED] wrote:

On Feb 26, 2004, at 11:14 AM, Riccardo Perotti wrote:

Can somebody point me in the right direction and / or contribute an
idea for
this?
Have a look at the man page for the 'killall' command. In short, it
signals processes by name, so you don't need to know the PID. You can
use system() to run it from Perl, like this:
#!/usr/bin/perl

use warnings;
use strict;
system 'killall -KILL pppd';

sherm--


Thanks Sherm! That definitely looks like a step in the right 
direction.

Now the only problem is that 'pppd' a process owned by root. Should my
script be run as 'root'? That sounds kind of dangerous! ... can it / 
should
it be done? When at the Terminal I have to 'sudo kill' and the get 
asked my
password. How would I do a 2 step process from 1 perl script?

Thanks again!

Riccardo



--
mailto:[EMAIL PROTECTED]
http://www.riccardoperotti.com




Long shot but worth a try...

2004-02-26 Thread Riccardo Perotti
This is not a problem/question with/about perl, but one that I think can be
solved *with* perl in macosx. Please forgive it's off-topicness:

Internet Connection in Panther 10.3.2 sometimes hangs forever in its
Disconnecting... status. I have not been able to find a reason nor a cure:
I've found people who also have this problem but the circumstances, causes
and systems all seem inconsistent. Restarting is the only solution for
GUI-only users (login out and back in won't do it).

I've been using the Terminal to find the process id whose name is 'pppd' via
top and then sudo-killing it (for some reason you have to kill it twice
before it finally dies [EMAIL PROTECTED]*!).

I though I'd write a perl script to do the process described above and share
it with the affected users community and feel good about it for a couple of
days. I've using perl for 5 years in self-contained programs that have
minimal interaction with the machine they run on, so it is only until now
that I come to realize my profound ignorance in this field: I was not even
able to take the first step : getting the process's id! I cannot find any
function resembling 'getpidbyname'.

Can somebody point me in the right direction and / or contribute an idea for
this?

TIA

Regards,


Riccardo
--
mailto:[EMAIL PROTECTED]
http://www.riccardoperotti.com