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.

Services Control

Help for those learning Tcl or writing their own scripts.
Post Reply
T
Talustus
Voice
Posts: 5
Joined: Mon Aug 28, 2006 5:57 pm

Services Control

Post by Talustus »

Hi @ all im not realy a coder but i need this i have writen a snippet but it didnt work whats wrong ? if Services are going down on one maschine i type !servcontrol and the bot will execute the command to start the services on the maschine but it says can not execute /home/test/sbnc/sbnc - permission denied so i would execute it as root

first snippet i have tested

Code: Select all

bind pub - !servcontrol pub_servcontrol
proc pub_servcontrol {nick uhost hand chan arg} {
putchan $chan "\00312...\00304trying to Start Services on Remote maschine "
set serv "/home/test/services/services"
eval exec $serv
}
<<<<<< didnt work i get the error can not execute /home/... -permission denied >>>>>>>>>

second snippet

Code: Select all

bind pub - !servcontrol pub_servcontrol
proc pub_servcontrol {nick uhost hand chan arg} {
putchan $chan "\00312...\00304trying to Start Services on Remote maschine "
set su "su root"
eval exec $su
set pw "pw here"
eval exec $pw
}
bind pub - !servstart pub_servstart
proc pub_servstart {nick uhost hand chan arg} {
exec "/home/test/services/services"
}
but it didnt work it means su: wrong password but the pw is corect
some ideas or is there a script thats looks every half hour
if Services are online {halt}
if Services are offline exec /home/test/services/services
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Services Control

Post by user »

Why are you trying to execute the password?
Talustus wrote:

Code: Select all

set pw "pw here"
eval exec $pw
I imagine you want something like this (not tested):

Code: Select all

bind pub n !test test
proc test args {
	if {[catch {
		set su [open "|su root -c /home/test/services/services" r+]
		putlog "SU(1): [read $su]"
		puts $su "rootpass";# CHANGE THIS
		putlog "SU(2): [read $su]"
		close $su
	} err]} {
		putlog $err
	}
}
...but having the root password in plain text in the script might not be such a bright idea. :roll:
Have you ever read "The Manual"?
Post Reply