This is the new home of the egghelp.org community forum. this announcement post . Click the X in the top right-corner of this box to dismiss this message. 
Help for those learning Tcl or writing their own scripts.
			
		
				
			
				
								EzMe 							 
						Voice 			
		Posts:  5 Joined:  Tue Jan 15, 2013 5:50 am 
		
						
					
													
							
						
									
						Post 
					 
								by EzMe  Wed Jan 16, 2013 6:05 am 
			
			
			
			
			
			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.
									
 
		 
				
		
		 
	 
				
		
				
			
				
								Madalin 							 
						Master 			
		Posts:  310 Joined:  Fri Jun 24, 2005 11:36 amLocation:  Constanta, Romania
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Madalin  Fri Jan 18, 2013 9:57 pm 
			
			
			
			
			
			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" 
} 
 
		 
				
		
		 
	 
				
		
				
			
				
								EzMe 							 
						Voice 			
		Posts:  5 Joined:  Tue Jan 15, 2013 5:50 am 
		
						
					
						 
													
							
						
									
						Post 
					 
								by EzMe  Mon Feb 04, 2013 8:08 am 
			
			
			
			
			
			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