egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Small exec question

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
EzMe
Voice


Joined: 15 Jan 2013
Posts: 5

PostPosted: Wed Jan 16, 2013 6:05 am    Post subject: [SOLVED] Small exec question Reply with quote

Lo all Smile

I'm trying to find out true a tcl script how long a linux application is running true the following script:

Code:

### !status
bind pub * !status pub_status
proc pub_status { nick host handle chan text} {
        catch { exec ps aux | grep -i rcracki_mt | awk '{print $10}' } status
        putmsg $chan "\002\0034::\003 rcrack is running for $status \002"
}


When I run it in bash it returns me for example the following information as expected:

Code:

[ezme@EzMe r2d2]$ ps aux | grep -i rcracki_mt | awk '{print $10}'
3:12


When I run it true my eggie

Code:

[10:11] <@EzMe> !status
[10:11] <R2D2> :: rcrack is running for can't read "10": no such variable


So it seems i need to put the command in quotes or something but that doesn't seem to work eather. Als i tried putting the command in a variable but again no succes.

Any idea's on how to tackle this problem?

Thanks in advanced Smile

Grtz EzMe


Last edited by EzMe on Mon Feb 04, 2013 8:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Fri Jan 18, 2013 9:57 pm    Post subject: Reply with quote

Try

Code:

### !status
bind pub * !status pub_status
proc pub_status { nick host handle chan text} {
        catch { exec ps aux | grep -i rcracki_mt | awk '{print \$10}' } status
        putmsg $chan "\002\0034::\003 rcrack is running for $status \002"
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
EzMe
Voice


Joined: 15 Jan 2013
Posts: 5

PostPosted: Mon Feb 04, 2013 8:08 am    Post subject: Reply with quote

I was able to fix it with this method:

Code:

### !status
bind pub * !status pub_status
proc pub_status { nick host handle chan text} {
        catch { exec ./status.sh } output
         set grr $output
        if {$grr == ""} {
              putmsg $chan "\002\0034::\003 rcrack is not running\002"
         return
      }
         if {$grr != "0:00"} {
              putmsg $chan "\002\0034::\003 rcrack is running for $grr minutes..\002"
   }
    close $grr
}


where status.sh contains the following line:


Code:
ps aux | grep -i '[r]cracki_mt' | awk '{print $10}'


Topic can be closed. Thanks for the reply Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber