By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,689 Members | 1,731 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,689 IT Pros & Developers. It's quick & easy.

Shell: run script

P: n/a
Can someone tell me how to run a script from a interactive shell

I type the following:
python filename
python filename.py
run filename
run filename.py
/run filename
/run filename.py


and in all cases I get errors. I can't believe I can not run
a script from the shell.

What am I doing wrong?????

Help!!!!!!!!!
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"leroybt.rm" <le*****@rocketmail.com> schrieb im Newsbeitrag
news:ma*************************************@pytho n.org...
| Can someone tell me how to run a script from a interactive shell
|
| I type the following:
|
| >>>python filename
| >>>python filename.py
| >>>run filename
| >>>run filename.py
| >>>/run filename
| >>>/run filename.py
You want to run a script from *inside the Python Interactive Shell*? Or do
you want to run a Python script (*.py) as a program from any (other than the
Python shell)? Or did you mix these two things up?
Vincent Wehren



| and in all cases I get errors. I can't believe I can not run
| a script from the shell.
|
| What am I doing wrong?????
|
| Help!!!!!!!!!
|
|
Jul 18 '05 #2

P: n/a
On Wed, 26 Nov 2003 18:40:05 +0000, leroybt.rm wrote:
Can someone tell me how to run a script from a interactive shell

I type the following:
python filename
python filename.py
run filename
run filename.py
/run filename
/run filename.py


and in all cases I get errors. I can't believe I can not run
a script from the shell.


Normally, you do not want to run your scripts from a Python shell,
but from the bash etc. (Linux shells) or from a DOS console
(Windows) etc. For this, you use:

python <path_to_file>

If you really want to run a script from the Python shell, the
following will do:

execfile("<path_to_file>")

HTL, L.
--
mailto: logan@phreaker(NoSpam).net

Jul 18 '05 #3

P: n/a
Dnia Wed, 26 Nov 2003 18:40:05 -0000, leroybt.rm napisał(a):
Can someone tell me how to run a script from a interactive shell


You mean interactive session? If yes, then do:

import os
os.system('/path/to/a/script')

--
[ Wojtek Walczak - gminick (at) underground.org.pl ]
[ <http://gminick.linuxsecurity.pl/> ]
[ "...rozmaite zwroty, matowe od patyny dawnosci." ]

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.