[ilugd] What's wrong with it???

2008-04-25 Thread devesh
hi guys,

Can anyone find something interesting ?

Well here is a shell script (kill.sh) :

  *#!/bin/bash
id=`ps -ef | grep wget | grep -v grep | cut -c 10-15`
if [ $id -eq 20698 ]
then
sleep 10m
sh kills.sh
else
date  kill_time
poweroff
fi

*
1.It was around 4.AM i run it background.And checked the PID of wget, it was
20698.
2.I slept and wake up at 8.40 AM and checked again.
3.PC was still ON. No kill.sh was running .No Wget process was running as
wget-log showed saved at 8.15AM.

question : why didn't pc go OFF.

4.Again I start : sh kill.sh ... PC went OFF. (of course it must be)

5.  Any comment(s)


Cheers,
Devesh.
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22-24, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] What's wrong with it???

2008-04-25 Thread Mehul Ved
On Fri Apr 25, 2008 at 10:21:31PM +0530, devesh wrote:
 hi guys,
 
 Can anyone find something interesting ?
 
 Well here is a shell script (kill.sh) :
 
   *#!/bin/bash
 id=`ps -ef | grep wget | grep -v grep | cut -c 10-15`

Probably you can active the same using pgrep?
id = `ps -ef | pgrep wget`

 if [ $id -eq 20698 ]
 then
 sleep 10m
 sh kills.sh
 else
 date  kill_time
 poweroff
 fi
 
 *
 1.It was around 4.AM i run it background.And checked the PID of wget, it was
 20698.
 2.I slept and wake up at 8.40 AM and checked again.
 3.PC was still ON. No kill.sh was running .No Wget process was running as
 wget-log showed saved at 8.15AM.
 
 question : why didn't pc go OFF.
 
 4.Again I start : sh kill.sh ... PC went OFF. (of course it must be)
 
 5.  Any comment(s)

I believe you're running this via cron. So, the user from whose cron
entry you're running it, can issue poweroff command?
Maybe you need to give full path to poweroff?
-- 
   Why can't I ever build character at a Miami condo or a casino somewhere?
  -- Calvin

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22-24, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] What's wrong with it???

2008-04-25 Thread आशीष शुक्ल Ashish Shukla
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

,--[ On Fri, Apr 25, 2008 at 10:21:31PM +0530, devesh wrote:
| hi guys,
| 
| Can anyone find something interesting ?
| 
| Well here is a shell script (kill.sh) :
| 
|   *#!/bin/bash
| id=`ps -ef | grep wget | grep -v grep | cut -c 10-15`
| if [ $id -eq 20698 ]

^^^ you should've wrapped $id in quotes, e.g. if [ $id -eq 20698 ]

| then
| sleep 10m
| sh kills.sh

^^^ a) name of your script, you mentioned on top is kill.sh
b) you should've used 'exec sh kill.sh' instead otherwise you'll
end up with a hundreds of 'kill.sh' instances.

| else
| date  kill_time
| poweroff
| fi
| 
| *
| 1.It was around 4.AM i run it background.And checked the PID of wget, it was
| 20698.
| 2.I slept and wake up at 8.40 AM and checked again.
| 3.PC was still ON. No kill.sh was running .No Wget process was running as
| wget-log showed saved at 8.15AM.
| 
| question : why didn't pc go OFF.
| 
| 4.Again I start : sh kill.sh ... PC went OFF. (of course it must be)

If in the first run of script, result of evaluatino false, then it'll get 
executed,
but not for subsequent times, because name of script is incorrect.

| 
| 5.  Any comment(s)

HTH
- -- 
Ashish Shukla आशीष शुक्ल  http://wahjava.wordpress.com/
·-- ·-  ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIEhpnHy+EEHYuXnQRAlfdAKCStoBvmphzsh0V46JjrBFroBXQFACgugW5
xpjtnNc1meXPE7pNZAP5GTQ=
=7eC6
-END PGP SIGNATURE-

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22-24, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] What's wrong with it???(Mehul Ved,,,Ashish Shukla)

2008-04-25 Thread devesh
Hi ,

Well i knew pgrep and it is same as i wrote in single line.NO ISSUE
about it.

I logged in as 'root' so poweroff could be invoked and path was  OK.

Moreover  the last point  I  again  did  'sh kills.sh'  PC WENT OFF.

Well, name of script was kills.sh not kill.sh always.

cheers,
Devesh.
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22-24, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/