0

I'm writing a script that opens ssh, connects to django, gets data from the app using python commands from the python script myscript.py. However the current code doesn't work.

#!/bin/bash
xterm -hold -e ssh server python /srv/django/manage.py shell execfile ./myscript

With this, I get a command error: Command doesn't accept any arguments

I also tried:

#!/bin/bash
xterm -e ssh server python /srv/django/manage.py shell execfile('./myscript.py')

but got a syntax error:

line 3: syntax error near unexpected token '('

3

You can try to put the all command into quotes:

#!/bin/bash
xterm -hold -e ssh server "python /srv/django/manage.py shell execfile ./myscript.py"

it should solve your problem.

  • the xterminal just disappears after i enter the passphrase – user65165 Jul 15 '15 at 18:54
  • 1
    yes. It executes the script and then exits. I recommend you to try the script syntax before trying in in xterm and ssh, just locally, like python /srv/django/manage.py shell execfile('./myscript.py') -- it has syntax errors. – Jakuje Jul 15 '15 at 18:57
  • 1
    Adding "-hold" to xterm will keep the window open, like xterm -hold -e ... – bistoco Jul 15 '15 at 19:04
  • when you try to copy & paste the code in my last comment into bash, it will show the syntax errors. Not sure what it should actually do. – Jakuje Jul 15 '15 at 19:05
  • 1
    Make sure the file myscript.py is in your home directory on server. There is problem in django/python command and here I can't help more. – Jakuje Jul 15 '15 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.