Search code examples
linuxbashshplink

PLINK command executes but no file created


I have wrote a bash file so If an user select a specific option then on a linux server a specific .sh file will execute.

For example:

If a user presses 1:

for %%? in (1) do if /I "%C%"=="%%?" goto print

:print
CLS
start C:\tools\PLINK.EXE -ssh -pw <password> -t <user>@10.111.11.111 "echo <password> | sudo -S /var/www/test/test.sh"

I can see the shell script starting but on my linux server "test.sh" has commands to create a .txt file.

echo $NAME "test" >> test.txt (for example)

My question now is... why is it if I run test.sh on the linux server directly the test.txt has been succesfully created.

If I run test.sh trough my windows batch file, I can see the command is activated but no test.txt file is created on the linux server.

Thank you for the help!


Solution

  • Either the test.txt will be in your HOME directory or you can give the entire path along with the test.txt to verify.