Re: Check if a command is valid

2010-07-14 Thread Grant Edwards
On 2010-07-14, Steven W. Orr wrote: > On 07/12/10 21:29, quoth Kenny Meyer: > >> I have to figure out if a string is callable on a Linux system. I'm >> actually doing this: >> >> def is_valid_command(command): >> retcode = 100 # initialize >> if command: >> retcode

Re: Check if a command is valid

2010-07-14 Thread Steven W. Orr
On 07/12/10 21:29, quoth Kenny Meyer: > Hello, > > I have to figure out if a string is callable on a Linux system. I'm > actually doing this: > > def is_valid_command(command): > retcode = 100 # initialize > if command: > retcode = subprocess.call(command, shell=Tr

Re: Check if a command is valid

2010-07-14 Thread Kenny Meyer
On Jul 13, 4:14 pm, Hans Mulder wrote: > Chris Rebert wrote: > > `where` seems to be a zsh built-in: > > $ # I'm in UR bash > > $ nonexistent > > -bash: nonexistent: command not found > > $ where bash > > -bash: where: command not found > > > And not everyone has zsh installed, so... > > I don't s

Re: Check if a command is valid

2010-07-13 Thread Shashwat Anand
On Tue, Jul 13, 2010 at 6:59 AM, Kenny Meyer wrote: > Hello, > > I have to figure out if a string is callable on a Linux system. I'm > actually doing this: > >def is_valid_command(command): >retcode = 100 # initialize >if command: >retcode = subprocess.call(command

Re: Check if a command is valid

2010-07-13 Thread Kenny Meyer
Chris Rebert (c...@rebertia.com) wrote: > On Mon, Jul 12, 2010 at 6:29 PM, Kenny Meyer wrote: > > Hello, > > > > I have to figure out if a string is callable on a Linux system. I'm > > "callable" seems vague. Is a command string with invalid arguments but > a valid executable "callable"? If no, t

Re: Check if a command is valid

2010-07-13 Thread Hans Mulder
Chris Rebert wrote: `where` seems to be a zsh built-in: $ # I'm in UR bash $ nonexistent -bash: nonexistent: command not found $ where bash -bash: where: command not found And not everyone has zsh installed, so... I don't see why one shouldn't use the standard `which` *nix command instead. Be

Re: Check if a command is valid

2010-07-13 Thread Chris Rebert
On Tue, Jul 13, 2010 at 4:33 AM, Jean-Michel Pichavant wrote: > Kenny Meyer wrote: >> I have to figure out if a string is callable on a Linux system. I'm >> actually doing this: >> >>    def is_valid_command(command): >>        retcode = 100 # initialize >>        if command: >>            retcode

Re: Check if a command is valid

2010-07-13 Thread Jean-Michel Pichavant
Kenny Meyer wrote: Hello, I have to figure out if a string is callable on a Linux system. I'm actually doing this: def is_valid_command(command): retcode = 100 # initialize if command: retcode = subprocess.call(command, shell=True) if retcode is 0:

Re: Check if a command is valid

2010-07-12 Thread Tim Roberts
Kenny Meyer wrote: > >I have to figure out if a string is callable on a Linux system. I'm >actually doing this: >... >Never mind the code, because this is not the original. >The side effect of subprocess.call() is that it *actually* executes >it, but I just need the return code. What are better wa

Re: Check if a command is valid

2010-07-12 Thread Chris Rebert
On Mon, Jul 12, 2010 at 6:29 PM, Kenny Meyer wrote: > Hello, > > I have to figure out if a string is callable on a Linux system. I'm "callable" seems vague. Is a command string with invalid arguments but a valid executable "callable"? If no, then there's no general way to test "callability" witho