-   Linux - Newbie (
-   -   cutting needed information (

Kendo1979 04-19-2005 08:55 PM

cutting needed information
i'm trying to learn scripting in linux

the script is like this


case "$1" in
echo "Starting $DESC: $NAME"
cd $DIR
screen -d -m -S $NAME $DAEMON

if [[ `screen -ls |grep $NAME` ]]
echo "The $DESC is up"
echo "$DESC is not running starting it"
cd $DIR
screen -d -m -S $NAME $DAEMON
echo -n " ... done."

echo "Usage: $0 {start|check}"
exit 1

exit 0

i want to modify it so that i can use cron to kill the program at certain time

when i try typing screen -ls | grep zon1 on console
it returns xxxxxx.zon1 where x is numbers

i tried typing kill 'screen -ls | grep zon1' but it won't kill the running program

if i type kill xxxx where xxx is the number i get from earlier, the program is instantly killed.

is there anyway that i can gain the 'xxxx' from 'xxxx.zon1' so that i can input t to 'kill' ?

any help will be apreciated.

bigrigdriver 04-19-2005 09:25 PM

when you typed 'screen -ls | grep zon1', did you use the apostrophe key (') or the backtick (`), left of the number 1 key (on the US keyboard). It makes a difference. Try it again with the backtick.

Kendo1979 04-19-2005 09:43 PM

yes i use kill `screen -ls | grep zon1`

the problem is `screen -ls | grep zon1` will result in xxxx.zon1
and kill syntax is followed by pid where xxx.zon1 is not a pid, hence failure.

is there anyway to cut xxx from xxx.zon1 ?

trevelluk 04-20-2005 08:10 AM

Yep, use the cut program:

echo `screen -ls | grep zon1` | cut -d'.' -f1

Kendo1979 04-20-2005 11:12 PM

thanks, i'll try this lates, coz i'm not on my box now :)


Kendo1979 04-21-2005 04:29 PM

thank you very much

i can use this

kill `screen -ls | grep zon1 | cut -d'.' -f1`

heuhuehuehuehu i never know that scripting can be this great

i must study more of linux :)

All times are GMT -5. The time now is 10:44 AM.