Not enough arguments for format string

K

Kevin Walzer

I'm getting an error in a Python script I'm writing: "not enough
arguments for format string." The error comes at the end of the
os.system command, referenced below. Any ideas?

---

import EasyDialogs
import os
import sys


password = EasyDialogs.AskPassword("To launch Ethereal, please enter
your password:")
binpath = os.path.join(os.path.dirname(sys.argv[0]),
'/opt/local/bin/ethereal')

os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
DISPLAY; echo %s | sudo -S %s; sudo -k' %password %binpath)

TypeError: not enough arguments for format string


--
Cheers,

Kevin Walzer, PhD
WordTech Software - "Tame the Terminal"
http://www.wordtech-software.com
sw at wordtech-software.com
 
P

Pierre Barbier de Reuille

Kevin Walzer a écrit :
I'm getting an error in a Python script I'm writing: "not enough
arguments for format string." The error comes at the end of the
os.system command, referenced below. Any ideas?

---

import EasyDialogs
import os
import sys


password = EasyDialogs.AskPassword("To launch Ethereal, please enter
your password:")
binpath = os.path.join(os.path.dirname(sys.argv[0]),
'/opt/local/bin/ethereal')

os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
DISPLAY; echo %s | sudo -S %s; sudo -k' %password %binpath)

TypeError: not enough arguments for format string

Well, just try :
os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
DISPLAY; echo %s | sudo -S %s; sudo -k' % (password, binpath) )

The reason is, you have 2 "%s" in yor string, thus after the "%"
operator, you need a 2-element tuple ! If you have either more or less
element, you'll get a TypeError ! In your code above you put a single
element ...

Pierre
 
J

James

Missing a comma there :)

So the line above should be:

os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
DISPLAY; echo %s | sudo -S %s; sudo -k' % (password binpath))

try that.

os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
DISPLAY; echo %s | sudo -S %s; sudo -k' % (password, binpath))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top