This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED] Small exec question

Help for those learning Tcl or writing their own scripts.
Post Reply
E
EzMe
Voice
Posts: 5
Joined: Tue Jan 15, 2013 5:50 am

[SOLVED] Small exec question

Post by EzMe »

Lo all :)

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

Code: Select all

### !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: Select all

[ezme@EzMe r2d2]$ ps aux | grep -i rcracki_mt | awk '{print $10}'
3:12
When I run it true my eggie

Code: Select all

[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 :)

Grtz EzMe
Last edited by EzMe on Mon Feb 04, 2013 8:09 am, edited 1 time in total.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Try

Code: Select all

### !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" 
} 
E
EzMe
Voice
Posts: 5
Joined: Tue Jan 15, 2013 5:50 am

Post by EzMe »

I was able to fix it with this method:

Code: Select all

### !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: Select all

ps aux | grep -i '[r]cracki_mt' | awk '{print $10}'
Topic can be closed. Thanks for the reply :)
Post Reply