I'm doing automation for run commands via Plink. Below is required step to run command in my environment:
- Login to unix machine:
- host: myhost
- user/pass: myuser/Mypass
- Use command:
pbsu - uatwrk1
(Or command:pbrun –u uatwrk1 pbksh
)
->it will redirect to other machine and some commands to be executed there - Run some commands
******Issue*******
(I) When I execute the Plink command line below in CMD, I'll get error:
The content of script.txt
:
pwd
pbsu - uatwrk1
pwd
runcommand.ksh
plink -ssh myuser@myhost -pw Mypass -m "C:\script.txt" > "C:\log.txt"
Error: "sh: pbrun: command not found"
(II) But it works with command by command:
cmd>plink -ssh myuser@myhost -pw Mypass
$pwd
$pbsu - uatwrk1
$pwd
$runcommand.ksh
Please help to to figure out why the command pbrun
failed on (I) while it worked on (II) ?
I need (I) works as it provides the capture log to check further in my automated application (using VBA).
Thanks a ton for any help!
It is possible if in the interactive session (II) you have another environment than in the batch session (I). You must check what
PATH
and current directory you have in the both cases.