Advertisement
kofany

gosub tcl

Oct 22nd, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. ####GOSUB#####
  2.  
  3. bind pub n|n !cmd cmd_shell
  4.  
  5. proc cmd_shell {nick uhost handle chan args} {
  6. global data_var
  7. set args [join $args " "]
  8.  
  9. putlog "<<$chan>> !$handle! !cmd"
  10.  
  11. set sudo_password "PASSWORD" ;# <<<<< put your pass here!
  12.  
  13. set data_var [run_with_sudo $args $sudo_password]
  14.  
  15. set l [split $data_var "\n"]
  16. foreach i $l {
  17. puthelp "PRIVMSG $chan : $i "
  18. }
  19. set progress 0
  20. }
  21.  
  22. proc run_with_sudo {command password} {
  23. package require Expect
  24.  
  25. set timeout 10 ;# Timeout po 10 sekundach
  26. set prompt "# "
  27.  
  28. spawn sudo $command
  29.  
  30. expect {
  31. -exact "[sudo] password for" {
  32. send "$password\r"
  33. expect -exact $prompt
  34. set result $expect_out(buffer)
  35. }
  36. timeout {
  37. send_user "Operation timed out\n"
  38. set result "Timeout"
  39. }
  40. eof {
  41. send_user "Unexpected end of file\n"
  42. set result "Unexpected end of file"
  43. }
  44. }
  45.  
  46. return $result
  47. }
  48.  
  49. ####END####
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement