Retrieving the output of subprocess.check_output()
up vote
-1
down vote
favorite
I'm trying to use subprocess.check_output
to iterate the shell command over a dictionary located in keyword_mappings
.
search.py
is the module that outputs the data in the database given an argument -f < keyword >
.
from etc.keyword_mappings import vuln_types as mappings
import subprocess
for k in mappings.items():
result = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
Passing k
to the command gives this error:
TypeError Traceback (most recent call last)
<ipython-input-102-e5e30903f491> in <module>()
4 for k in mappings.items():
5 #command = './bin/search.py -f %s'
---> 6 p = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
TypeError: not all arguments converted during string formatting
The command works normally in the shell.
python
add a comment |
up vote
-1
down vote
favorite
I'm trying to use subprocess.check_output
to iterate the shell command over a dictionary located in keyword_mappings
.
search.py
is the module that outputs the data in the database given an argument -f < keyword >
.
from etc.keyword_mappings import vuln_types as mappings
import subprocess
for k in mappings.items():
result = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
Passing k
to the command gives this error:
TypeError Traceback (most recent call last)
<ipython-input-102-e5e30903f491> in <module>()
4 for k in mappings.items():
5 #command = './bin/search.py -f %s'
---> 6 p = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
TypeError: not all arguments converted during string formatting
The command works normally in the shell.
python
3
k
is a 2-tuple, how would that match with one%s
?
– Willem Van Onsem
Nov 9 at 19:03
This doesn't directly solve your problem, but are you sure you want to usesubprocess
to begin with? Conventionally, one usesimport
to execute a Python script from another Python script.
– Kevin
Nov 9 at 19:06
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to use subprocess.check_output
to iterate the shell command over a dictionary located in keyword_mappings
.
search.py
is the module that outputs the data in the database given an argument -f < keyword >
.
from etc.keyword_mappings import vuln_types as mappings
import subprocess
for k in mappings.items():
result = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
Passing k
to the command gives this error:
TypeError Traceback (most recent call last)
<ipython-input-102-e5e30903f491> in <module>()
4 for k in mappings.items():
5 #command = './bin/search.py -f %s'
---> 6 p = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
TypeError: not all arguments converted during string formatting
The command works normally in the shell.
python
I'm trying to use subprocess.check_output
to iterate the shell command over a dictionary located in keyword_mappings
.
search.py
is the module that outputs the data in the database given an argument -f < keyword >
.
from etc.keyword_mappings import vuln_types as mappings
import subprocess
for k in mappings.items():
result = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
Passing k
to the command gives this error:
TypeError Traceback (most recent call last)
<ipython-input-102-e5e30903f491> in <module>()
4 for k in mappings.items():
5 #command = './bin/search.py -f %s'
---> 6 p = subprocess.check_output('./bin/search.py -f %s' % k, shell=True)
TypeError: not all arguments converted during string formatting
The command works normally in the shell.
python
python
edited Nov 9 at 19:15
pushkin
3,673102450
3,673102450
asked Nov 9 at 19:02
Lowly0palace
112
112
3
k
is a 2-tuple, how would that match with one%s
?
– Willem Van Onsem
Nov 9 at 19:03
This doesn't directly solve your problem, but are you sure you want to usesubprocess
to begin with? Conventionally, one usesimport
to execute a Python script from another Python script.
– Kevin
Nov 9 at 19:06
add a comment |
3
k
is a 2-tuple, how would that match with one%s
?
– Willem Van Onsem
Nov 9 at 19:03
This doesn't directly solve your problem, but are you sure you want to usesubprocess
to begin with? Conventionally, one usesimport
to execute a Python script from another Python script.
– Kevin
Nov 9 at 19:06
3
3
k
is a 2-tuple, how would that match with one %s
?– Willem Van Onsem
Nov 9 at 19:03
k
is a 2-tuple, how would that match with one %s
?– Willem Van Onsem
Nov 9 at 19:03
This doesn't directly solve your problem, but are you sure you want to use
subprocess
to begin with? Conventionally, one uses import
to execute a Python script from another Python script.– Kevin
Nov 9 at 19:06
This doesn't directly solve your problem, but are you sure you want to use
subprocess
to begin with? Conventionally, one uses import
to execute a Python script from another Python script.– Kevin
Nov 9 at 19:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
items() returns a list of (key, value) tuples
for k,v in mappings.items():
...
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
items() returns a list of (key, value) tuples
for k,v in mappings.items():
...
add a comment |
up vote
0
down vote
items() returns a list of (key, value) tuples
for k,v in mappings.items():
...
add a comment |
up vote
0
down vote
up vote
0
down vote
items() returns a list of (key, value) tuples
for k,v in mappings.items():
...
items() returns a list of (key, value) tuples
for k,v in mappings.items():
...
answered Nov 9 at 19:20
nlsdkd
814
814
add a comment |
add a comment |
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%2fstackoverflow.com%2fquestions%2f53231843%2fretrieving-the-output-of-subprocess-check-output%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
3
k
is a 2-tuple, how would that match with one%s
?– Willem Van Onsem
Nov 9 at 19:03
This doesn't directly solve your problem, but are you sure you want to use
subprocess
to begin with? Conventionally, one usesimport
to execute a Python script from another Python script.– Kevin
Nov 9 at 19:06