-1

I am trying to run the Unix command from Load Runner using popen. I tried step by step approach below are they

Step 1 : I first tried logging into the Jump Server

fp = popen("plink.exe -ssh -l username -pw password Servername", "r");

Output using above command in Load runner : Last login: Thu Jan 11 11:11:11 2018 from some.machine.net

Output manually using Putty : Using username "abcdef". Last login: Thu Jan 11 11:11:11 2018 from some.machine.net abcdef@mymachine:~>

I successfully able to capture the desired result

Step 2 : I want to execute ls command once I am logged into the Jump Server, so I appended the ls command to the above command in the popen

fp = popen("plink.exe -ssh -l username -pw password Servername ls", "r");

then no output is produced and I get an error

In step 1 I am able to capture the output which is "Last login: Thu Jan 11 11:11:11 2018 from some.machine.net" But in step 2 when I am trying to execute the ls command just by appending in the same popen statement I am getting error.

My objective is to read the output of the ls command

user4021949
  • 243
  • 5
  • 13

1 Answers1

0

some_command is not appended.

popen("plink.exe -ssh -l username -pw password Servername some_command", "r")

should be changed into

popen("plink.exe -ssh -l username -pw password Servername ${some_command}", "r")
Ghlen
  • 659
  • 4
  • 14
  • I am trying to execute popen("plink.exe -ssh -l username -pw password Servername ls "r") – user4021949 Jan 12 '18 at 11:19
  • 1
    well, is the value of the variable ls equal to "ls"? Or did you mean to assign the string "ls" instead of the variable to some_command? try this: some_command = "ls"; – Ghlen Jan 12 '18 at 11:23
  • 1
    could you show us the error as well? What's happening now is anyones guess. – Ghlen Jan 12 '18 at 11:29
  • I am just getting nothing inside the buffer, count = fread(buffer, sizeof(char), BUFFER_SIZE, fp); and count is 0 – user4021949 Jan 12 '18 at 11:40