-1
Echo Enter the Report ID

read varname

ssh -t root@192.168.10.10 '
  python myscript.py --user User1 --password Password1 --report \$varname
'

I am trying pass an argument 'varname' to a remotely located python script using ssh but unable to do so. Getting an error 'Invalid report uuid provided'

Value for --report looks like as follow efc4c534-5d1d-11e9-844b-fa163e069095

Yogesh
  • 49
  • 8

1 Answers1

1

varname is defined locally only, so $varname needs to be expanded:

Echo Enter the Report ID

read varname

ssh -t root@192.168.10.10 "python myscript.py --user User1 --password Password1 --report $varname"
Keldorn
  • 1,980
  • 15
  • 25
  • Depending on the value of `varname`, its expansion may need to be quoted on the remote end. `ssh ... "python ... '$varname'"` would suffice as long as you can guarantee that `$varname` itself doesn't contain any single quotes. If it could, things get a lot trickier. – chepner Apr 17 '19 at 01:26
  • Good point. In the case of OP's example (efc4c534-5d1d-11e9-844b-fa163e069095), that will probably not be necessary. – Keldorn Apr 17 '19 at 01:32
  • The sketchy thing is, though, that you are logging in to a machine as root using a script that effectively lets you run arbitrary code: consider `varname="; echo gotcha"`. It would be a good idea to validate `varname` against the expected input format and only run `ssh` if the validation succeeds. – chepner Apr 17 '19 at 01:38
  • True. Feel free to edit or delete my answer. This question looks like a duplicate anyway, and has a negative vote. – Keldorn Apr 17 '19 at 01:47