Passing Command Line Argument to Python Script causes program failure, but creating a local variable in its...
Examples of smooth manifolds admitting inbetween one and a continuum of complex structures
I would say: "You are another teacher", but she is a woman and I am a man
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
CAST throwing error when run in stored procedure but not when run as raw query
Extract rows of a table, that include less than x NULLs
Is it inappropriate for a student to attend their mentor's dissertation defense?
Why is consensus so controversial in Britain?
Arrow those variables!
Intersection Puzzle
Detention in 1997
Personal Teleportation: From Rags to Riches
Should I cover my bicycle overnight while bikepacking?
How can I determine if the org that I'm currently connected to is a scratch org?
Which is the best way to check return result?
Do UK voters know if their MP will be the Speaker of the House?
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
What exploit Are these user agents trying to use?
Unlock My Phone! February 2018
Short story with a alien planet, government officials must wear exploding medallions
What is a romance in Latin?
Why didn't Boeing produce its own regional jet?
Why doesn't using multiple commands with a || or && conditional work?
How do I deal with an unproductive colleague in a small company?
What do you call someone who asks many questions?
Passing Command Line Argument to Python Script causes program failure, but creating a local variable in its place, program runs properly
Setting and getting Windows environment variables from the command prompt?Set Global Variable in Subroutine with IF in Windows BatchHow to make side-by-side Python 2.7 and 3.2 installs on Ubuntu 12.04,Is there a tool similar to IEpxress or 7Zip that can pass command line arguments to a dependencySetting Environment variables in Windows 10, to be able to run Python from cmdwindows batch complex -o parameter for youtube-dl - how to properly format?List specific files from a directoryScipy installation in localModuleNotFoundError: No module named 'distutils.core'What would the batch equivalent of Python's “pass” argument be?
Basically, I am writing a python script called detect.py. It will take in one argument from the command line (the argument is an integer, either 1 or 2). The detect.py script passes that argument into a batch file, which specifies a .dcs which is then run in an external tool. However, when I run the program like this, I get an error in the tool saying that the .dcs file is not found.
If I run the program without using the command line, on my own IDE (PyCharm), and just create a local variable (i.e. select = r'1' or r'2') and pass that into the batch file, I don't encounter any issues.
I am not sure what the issue is. I have tried casting the command line argument and making sure it is the proper type, I have verified the contents of the variable passed to the batch file is correct, but it still fails in every situation. Does python interpret the Command Line in such a way that causes this issue? I am at a loss here...
CODE SNIPPET:
def main(select):
"""
Main function
:param select: number of the quick connect channel in DET
can only be 1 or 2
"""
import subprocess
#List that holds the specific values for the channel select
chan_select = [r'1' , r'2']
chan = chan_select[int(select) - 1]
#UPDATE PATH VARIABLE AS NEEDED
PATH_FOR_DET_EXE = r'C:usersXXXXXDocumentsFord NetComDiagnostic Engineering Tool'
#variables to store log files
logReadName = '..\RESULT_LOGS\FDB1_Result.txt'
LUTname = '..\RESULT_LOGS\variantLUT.txt'
#PASS VARIABLES INTO BATCH FILE AND EXECUTE THE READ FDB1 BATCH FILE
subprocess.call([r'C:_FG41_AUTO_CI_STRATEGYFDB1_CheckBATCH_CMDRead_FDB1.bat', PATH_FOR_DET_EXE, chan], shell=True)
if __name__ == "__main__":
import sys
"""
**if I hard code the param passed to main
ex) select = r'1'
I have no issues**
"""
channel = sys.argv[1]
main(channel)
command-line batch python
New contributor
add a comment |
Basically, I am writing a python script called detect.py. It will take in one argument from the command line (the argument is an integer, either 1 or 2). The detect.py script passes that argument into a batch file, which specifies a .dcs which is then run in an external tool. However, when I run the program like this, I get an error in the tool saying that the .dcs file is not found.
If I run the program without using the command line, on my own IDE (PyCharm), and just create a local variable (i.e. select = r'1' or r'2') and pass that into the batch file, I don't encounter any issues.
I am not sure what the issue is. I have tried casting the command line argument and making sure it is the proper type, I have verified the contents of the variable passed to the batch file is correct, but it still fails in every situation. Does python interpret the Command Line in such a way that causes this issue? I am at a loss here...
CODE SNIPPET:
def main(select):
"""
Main function
:param select: number of the quick connect channel in DET
can only be 1 or 2
"""
import subprocess
#List that holds the specific values for the channel select
chan_select = [r'1' , r'2']
chan = chan_select[int(select) - 1]
#UPDATE PATH VARIABLE AS NEEDED
PATH_FOR_DET_EXE = r'C:usersXXXXXDocumentsFord NetComDiagnostic Engineering Tool'
#variables to store log files
logReadName = '..\RESULT_LOGS\FDB1_Result.txt'
LUTname = '..\RESULT_LOGS\variantLUT.txt'
#PASS VARIABLES INTO BATCH FILE AND EXECUTE THE READ FDB1 BATCH FILE
subprocess.call([r'C:_FG41_AUTO_CI_STRATEGYFDB1_CheckBATCH_CMDRead_FDB1.bat', PATH_FOR_DET_EXE, chan], shell=True)
if __name__ == "__main__":
import sys
"""
**if I hard code the param passed to main
ex) select = r'1'
I have no issues**
"""
channel = sys.argv[1]
main(channel)
command-line batch python
New contributor
add a comment |
Basically, I am writing a python script called detect.py. It will take in one argument from the command line (the argument is an integer, either 1 or 2). The detect.py script passes that argument into a batch file, which specifies a .dcs which is then run in an external tool. However, when I run the program like this, I get an error in the tool saying that the .dcs file is not found.
If I run the program without using the command line, on my own IDE (PyCharm), and just create a local variable (i.e. select = r'1' or r'2') and pass that into the batch file, I don't encounter any issues.
I am not sure what the issue is. I have tried casting the command line argument and making sure it is the proper type, I have verified the contents of the variable passed to the batch file is correct, but it still fails in every situation. Does python interpret the Command Line in such a way that causes this issue? I am at a loss here...
CODE SNIPPET:
def main(select):
"""
Main function
:param select: number of the quick connect channel in DET
can only be 1 or 2
"""
import subprocess
#List that holds the specific values for the channel select
chan_select = [r'1' , r'2']
chan = chan_select[int(select) - 1]
#UPDATE PATH VARIABLE AS NEEDED
PATH_FOR_DET_EXE = r'C:usersXXXXXDocumentsFord NetComDiagnostic Engineering Tool'
#variables to store log files
logReadName = '..\RESULT_LOGS\FDB1_Result.txt'
LUTname = '..\RESULT_LOGS\variantLUT.txt'
#PASS VARIABLES INTO BATCH FILE AND EXECUTE THE READ FDB1 BATCH FILE
subprocess.call([r'C:_FG41_AUTO_CI_STRATEGYFDB1_CheckBATCH_CMDRead_FDB1.bat', PATH_FOR_DET_EXE, chan], shell=True)
if __name__ == "__main__":
import sys
"""
**if I hard code the param passed to main
ex) select = r'1'
I have no issues**
"""
channel = sys.argv[1]
main(channel)
command-line batch python
New contributor
Basically, I am writing a python script called detect.py. It will take in one argument from the command line (the argument is an integer, either 1 or 2). The detect.py script passes that argument into a batch file, which specifies a .dcs which is then run in an external tool. However, when I run the program like this, I get an error in the tool saying that the .dcs file is not found.
If I run the program without using the command line, on my own IDE (PyCharm), and just create a local variable (i.e. select = r'1' or r'2') and pass that into the batch file, I don't encounter any issues.
I am not sure what the issue is. I have tried casting the command line argument and making sure it is the proper type, I have verified the contents of the variable passed to the batch file is correct, but it still fails in every situation. Does python interpret the Command Line in such a way that causes this issue? I am at a loss here...
CODE SNIPPET:
def main(select):
"""
Main function
:param select: number of the quick connect channel in DET
can only be 1 or 2
"""
import subprocess
#List that holds the specific values for the channel select
chan_select = [r'1' , r'2']
chan = chan_select[int(select) - 1]
#UPDATE PATH VARIABLE AS NEEDED
PATH_FOR_DET_EXE = r'C:usersXXXXXDocumentsFord NetComDiagnostic Engineering Tool'
#variables to store log files
logReadName = '..\RESULT_LOGS\FDB1_Result.txt'
LUTname = '..\RESULT_LOGS\variantLUT.txt'
#PASS VARIABLES INTO BATCH FILE AND EXECUTE THE READ FDB1 BATCH FILE
subprocess.call([r'C:_FG41_AUTO_CI_STRATEGYFDB1_CheckBATCH_CMDRead_FDB1.bat', PATH_FOR_DET_EXE, chan], shell=True)
if __name__ == "__main__":
import sys
"""
**if I hard code the param passed to main
ex) select = r'1'
I have no issues**
"""
channel = sys.argv[1]
main(channel)
command-line batch python
command-line batch python
New contributor
New contributor
New contributor
asked 1 hour ago
JMB94JMB94
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
JMB94 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1421139%2fpassing-command-line-argument-to-python-script-causes-program-failure-but-creat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
JMB94 is a new contributor. Be nice, and check out our Code of Conduct.
JMB94 is a new contributor. Be nice, and check out our Code of Conduct.
JMB94 is a new contributor. Be nice, and check out our Code of Conduct.
JMB94 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1421139%2fpassing-command-line-argument-to-python-script-causes-program-failure-but-creat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown