After we compile a C program, we can put the executable file under a
directory (like /bin) so that we can run it everywhere, and don't have to
type the full path.
Can we do the same thing to a python script?
For example, I have a script.py under "/home/john/". Can I just type "python
script.py" to run it under another directory "/home/tom/"?
Thanks!
Yang 2 2597
myang wrote: After we compile a C program, we can put the executable file under a directory (like /bin) so that we can run it everywhere, and don't have to type the full path. Can we do the same thing to a python script? For example, I have a script.py under "/home/john/". Can I just type "python script.py" to run it under another directory "/home/tom/"?
Make sure it has a proper bangpath, make it executable, and then put it
somewhere in your PATH. Then you can run it no matter what your pwd is
with
script.py
--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ Courage is the fear of being thought a coward.
-- Horace Smith
"myang" <my***@clarku.e du> wrote in message
news:ma******** *************** ************@py thon.org... After we compile a C program, we can put the executable file under a directory (like /bin) so that we can run it everywhere, and don't have to type the full path. Can we do the same thing to a python script? For example, I have a script.py under "/home/john/". Can I just type
"python script.py" to run it under another directory "/home/tom/"? Thanks!
Yang
It appears that you are on a UNIX system. Most systems will support
"shebang" proceesing of the first line in the file. The first line tells
UNIX to find 'python' in the PATH and run it to exectute this script. Use
'man env' for more information.
#! /usr/bin/env python
import os
import sys
....
When you do this, you do not need to uses the word 'python' on the command.
At the '$' prompt, just use:
script.py
The first line tells it to use Python to process the file. Of course
/home/john where the script.py file exists must be in the PATH variable in
order to run it from anywhere. Just like you have /bin in your PATH
variable already. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Larry Woods |
last post by:
I need to execute a Windows script (wscript/cscript) from an ASP page for
some administrative functions. Anyone doing this? If so, how?
TIA,
Larry Woods
|
by: Tomasz Ludwiniak |
last post by:
Hi,
I've little problem... I try to execute asp file ( which return XML file )
and use the result it in my asp script :
set xml = Server.CreateObject("MSXML2.DOMDocument")
xml.async=false
xml.load(Server.Execute("script.xml.asp"))
but it doesn;t work !
|
by: Toni Mcintyre |
last post by:
i'm having 2 problems with the http://validator.w3.org
1. if i have:
<meta http-equiv="Content-Script-Type" content="text/javascript">
then why do i need <script type=text/javascript> everywhere???
i'm writing most of my code by hand, so this is a lot of extra typing or
global search and replace later
2. the other problem is with my include files:
i usually <script src="foo.js"></script>
|
by: Matt |
last post by:
I used to execute a command line script in IIS 4 using Dynuexec. This
is a third part server object I installed on the server
(http://www.dynu.com/dynuexec.asp). I installed this object onto my
Windows 2003 Server and I cannot run the script from an ASP. No error
is generated on the screen or in the event log. I think this has
something to do with IIS not being able to access cmd.exe from IIS or
maybe with COM permissions? Not sure though....
|
by: Lyle Fairfield |
last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model
almost any MS-SQL object as a simple script file with a default ".sql"
extension.
But how to "run these files? They are in a slightly modifies character set
and contain commands only usable by the Server's SQL utilities. If one
tries to use them on a machine which does not have the SQL utilities
installed, one seems to have a laborious cut-and-paste task.
(Of...
| |
by: sohan |
last post by:
Hi,
I want to know how to connect and execute a db2 query from inside a
UNIX shell script.
Details: We have a unix shell script. We need to execute multiple db2
sql queries from this shell script and export the result to a file.
Any code snippet on this will be helpful.
|
by: Chr1s |
last post by:
How do I execute a crontab command using php (not CLI) as user Joe?
I don't have any problem getting output from commands such as 'ls'
using passthru and exec but I am stumped with crontab.
Many thanks!
Chris
|
by: maya |
last post by:
hi,
I keep getting this error, "can't execute code from a freed script" when
I go to another page (i.e., upon UNLOAD..)
this error occurs only in IE, not FF (what a surprise.....;)
what is this error, pls.. it's for a site I've been working on for a
few weeks now, started getting this error just a few days ago.. (I
looked this up, saw that often this error has to do with frames, but my
|
by: Bogdan |
last post by:
Hi,
I'd like to display (i.e. make visible) a label after a submit button is
clicked but only if the client-side validation is successful. If I did not
care about the validation then I'd simply modify style.display of the label
in my onclick (OnClientClick) script. The problem is that my script will
execute before the validation script.
Is there a way to execute my custom script after the validation takes place?
Thanks,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |