1

I have a batch file with 2 commands as below

echo y | "%10\putty\plink.exe" -ssh %6@%1 -pw "%7" exit
"%10\putty\plink.exe" -ssh %6@%1 -pw "%7" "/u01/./script.sh %1 %2 %3 %4 %5 %6 %7 %8 %9"

As you can see it takes 10 parameters from another program which calls this batch.

The issue here is with the 10th parameter, as we can only use parameter upto %9 and after that %10 is considered as %1 i.e. first parameter and 0 as another value.

How I can solve this?

I have checked this How to pass more than 9 parameters to batch file , However in my case the parameter positions are different as the first parameter passed to command is actually the 10th parameter passed from the program i.e. echo y | "%10\putty\plink.exe"

I'm a bit out of clue how i can use shift here.

Please help !!

EDIT:

I tried to change the position of parameter from program call itself such that i just have to pass the 10th parameter like this:

echo y | "%1\putty\plink.exe" -ssh %7@%2 -pw "%8" exit
"%1\putty\plink.exe" -ssh %7@%2 -pw "%8" "/u01/./script.sh %2 %3 %4 %5 %6 %7 %8 %9
shift
shift
shift
shift
shift
shift
shift
shift
shift
shift %1"

And parameters passed was as expected, but the issue here is the command is not getting executed in one go.

i.e.

"%1\putty\plink.exe" -ssh %7@%2 -pw "%8" "/u01/./script.sh %2 %3 %4 %5 %6 %7 %8 %9 %10"

is a single command however shift is also getting executed as command.

Rahul
  • 191
  • 1
  • 11
  • 2
    How about this solution? https://stackoverflow.com/questions/21694861/how-to-pass-more-than-9-parameters-to-batch-file – moritz.vieli Sep 25 '18 at 04:46
  • 1
    You could store the 9th argument in an interim environment variable (`set ARG9=%9`), then do `shift /9`, so `%9` actually points to the 10th argument, and the 9th one is still available in `%ARG9%`... – aschipfl Sep 25 '18 at 09:25
  • `%*` - retype all args, or use part of value `%CmdCmdLine%` – penknife Sep 25 '18 at 13:43

0 Answers0