Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####GOSUB#####
- bind pub n|n !cmd cmd_shell
- proc cmd_shell {nick uhost handle chan args} {
- global data_var
- set args [join $args " "]
- putlog "<<$chan>> !$handle! !cmd"
- set sudo_password "PASSWORD" ;# <<<<< put your pass here!
- set data_var [run_with_sudo $args $sudo_password]
- set l [split $data_var "\n"]
- foreach i $l {
- puthelp "PRIVMSG $chan : $i "
- }
- set progress 0
- }
- proc run_with_sudo {command password} {
- package require Expect
- set timeout 10 ;# Timeout po 10 sekundach
- set prompt "# "
- spawn sudo $command
- expect {
- -exact "[sudo] password for" {
- send "$password\r"
- expect -exact $prompt
- set result $expect_out(buffer)
- }
- timeout {
- send_user "Operation timed out\n"
- set result "Timeout"
- }
- eof {
- send_user "Unexpected end of file\n"
- set result "Unexpected end of file"
- }
- }
- return $result
- }
- ####END####
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement