Issue
After establishing an SSH connection I've tried the following command to move a file from one folder to another one and renaming it:
command='cp /test/trial test/attempt/trial_something'
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)
and it worked. Now I've tried, without success, to modify the command in this way:
command_test='/test/trial'
command='cp command_test test/attempt/trial_something'
print (command)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)
the result of the print is
cp command_test test/attempt/trial_something
so basically the string is not build as the one in first example.
Solution
I think I've found a way:
command_test='/test/trial'
command='cp ' + command_test + ' test/attempt/trial_something'
print (command)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(command)
this worked to me.
Answered By - martinmistere Answer Checked By - Katrina (WPSolving Volunteer)