Using “konsole” command to run python script

余生长醉 提交于 2019-12-08 03:49:20

问题


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?


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/10129750/using-konsole-command-to-run-python-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!