I am running a bat file from windows command line which calls a linux script to copy a file:
WIN_BATCH.bat content:
"C:\plink.exe" -ssh User@%1 -pw "pass123" "/u01/./LINUX_COPY_SCRIPT.sh %1"
LINUX_COPY_SCRIPT content as below:
sshpass -p "pass123" scp /u01/file_1.txt root@$1:/u01/file_1_Copy.txt
When I am running command from Win cmd as below, evereything is working fine, i.e.
Win command prompt:
C:\Scripts>WINbatch.bat 11.111.11.11
Message in CMD:
C:\Scripts>"C:\plink.exe" -ssh [email protected] -pw "pass123" "/u01/./LINUX_COPY_SCRIPT.sh 11.111.11.11"
C:\Scripts>
And the file gets copied from "file_1.txt" to "file_1_Copy.txt"
Now comes the issue, if I modify my scripts as below:
WIN_BATCH.bat content:
"C:\plink.exe" -ssh User@%1 -pw "pass123" "/u01/./LINUX_COPY_SCRIPT.sh %2"
LINUX_COPY_SCRIPT content as below:
sshpass -p "pass123" scp /u01/file_1.txt root@$2:/u01/file_1_Copy.txt
and pass 2 parameter:
Win command prompt:
C:\Scripts>WINbatch.bat 11.111.11.11 11.111.11.11
I'm getting error:
C:\Scripts>"C:\plink.exe" -ssh [email protected] -pw "pass123" "/u01/./LINUX_COPY_SCRIPT.sh 11.111.11.11"
ssh: Could not resolve hostname : Name or service not known
lost connection
C:\Scripts>
WHY ?? If you see the commands fired in both cases are same, as i am passing the same parameter.
HOW I CAN GET THIS WORKING ? The idea to pass multiple parameter because i want to copy file from one env to other at later stage.
I.e. once
C:\Scripts>WINbatch.bat 11.111.11.11 11.111.11.11
is working I'll be doing
C:\Scripts>WINbatch.bat 11.111.11.11 11.111.11.12
Where "11.111.11.11" and "11.111.11.12" are ip of 2 systems.
%2so the shell script can't access$2as it is not present.