abalter
abalter

Reputation: 10383

Using "konsole" command to run python script

I'm trying to, from a command line, open an instance of konsole and run a python script. I'm trying:

konsole -hold -e  'python -i hello.py'

The behaviour I'm getting is that a persistent konsole opens, and I am dropped into python, but the script does not run.

Python 2.7.2+ (default, Oct  4 2011, 20:03:08) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

What do I need to do to get the python script to run in the konsole window?

Upvotes: 1

Views: 3650

Answers (2)

Marty
Marty

Reputation: 8260

jsbueno's solution is the correct one. However, as described here, you can also do something like this ...

konsole --hold -e /bin/sh -c "python -i hello.py"

P.S. you'll need to specify --workdir (before the -e arg), or provide the full path to the python script, if it's not always in the initial working dir of konsole. But, you probably already knew that.

Upvotes: 2

jsbueno
jsbueno

Reputation: 110261

The problem is the way "konsole" uses the parameters after the -e switch - it seems like it simply pass them in a call that does not interpret the space separators as parameter separators.

However, if you don't put your call parameters inside quotes it will work - that is, simply:

konsole --hold -e  python -i hello.py

(I just tested it here)

Upvotes: 2

Related Questions