0

I want to run the pbrun command to login and remove some files in the server but when using the below command pbrun command asking password, is there any way we can pass password also?

#!/usr/bin/expect -f
pbrun ehuid
expect -exact "Password: "
send -- "password"
expect {\$\s*} { interact }

the above script not working and expect key not found issue coming

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
rakesh kandukuri
  • 195
  • 1
  • 11
  • Read the docs for how you tell expect to start a program. You don't just type the program name, you tell expect you want it to _spawn_ the program. – Charles Duffy Jul 18 '23 at 20:15
  • This is not a sh question or a shell question at all, because expect scripts are not shell scripts; that's why the shell-script approach of just typing the program name and arguments doesn't work. Rather, `expect` is an extension of the TCL language, so your expect scripts need to follow TCL syntax rules, not sh syntax rules. – Charles Duffy Jul 18 '23 at 20:16
  • (the linked duplicate is talking about starting a shell script from expect, but shell scripts -- at least, proper executable ones with a shebang and +x permissions -- are no different from any kind of other executable in this context). – Charles Duffy Jul 18 '23 at 20:18

0 Answers0