473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

passing a variable to an external program

I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.

An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')

When I run this, everything after pathname + seems to be ignored. Is
this just incorrect syntax or am I trying to do something fundamentally
wrong? Is there a better way to do something like this? I'm trying to
move from perl to python and this is my first attempt at python.

Jan 11 '07 #1
2 1288
On 2007-01-11, Rich <ri*******@gmail.comwrote:
I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.

An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')
Use / instead of \, or \\ instead of \.

--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
Jan 11 '07 #2
Thank you, that did it. I don't know why I didn't think to escape the
\ with \\.

On Jan 11, 2:18 pm, Neil Cerutti <horp...@yahoo.comwrote:
On 2007-01-11, Rich <richfa...@gmail.comwrote:
I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.
An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')Use / instead of \, or \\ instead of \.

--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
Jan 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rigga | last post by:
Hi I would like to pass a variable to an external program i.e. os.system('cd $variable') However this doesnt work, I cant figure it out, any ideas? Cheers
10
by: Rigga | last post by:
Hi, Ok first please bear with me as I am a total Python n00b.. Can anyone explain why this does not like me using % FileLoc in the os.system call??? #!/usr/bin/python import sys import os
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
5
by: kinne | last post by:
Is it possible to pass a parameter to an external ".js" file? Kinne
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
6
by: Paul M | last post by:
Hi All, I'm currently writing a z/OS DB2 Stored Proc in C, using an example from the IBM Stored Procedure guide (SG24-7083-00). The database calls to read and update the database work...
14
by: BrendanMcPherson | last post by:
Hello, Im try to do some tricks to help make a "Search Many Sites from One Location". http://www.act.org.au/b_nexus.htm What I have decided to do is this: 1. You can choose which site you...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
11
by: whirlwindkevin | last post by:
I saw a program source code in which a variable is defined in a header file and that header file is included in 2 different C files.When i compile and link the files no error is being thrown.How is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.