Is there something built-in for this ?

  • Thread starter Thibaut Barrère
  • Start date
T

Thibaut Barrère

Hi,

very often I use this method:

def launch(cmd)
raise "Error launching #{cmd}" unless system(cmd)
end

Is there a built-in equivalent ?

cheers,

-- Thibaut
 
A

Aldric Giacomoni

Thibaut said:
Hi,

very often I use this method:

def launch(cmd)
raise "Error launching #{cmd}" unless system(cmd)
end

Is there a built-in equivalent ?

cheers,

-- Thibaut
begin
system(cmd)
rescue NameError => e
puts e
end

.... Does that help you ?

--Aldric
 
T

Thibaut Barrère

begin
  system(cmd)
rescue NameError => e
  puts e
end

... Does that help you ?

hum -- not sure actually. Is system() supposed to raise a NameError ?
I didn't see this mentioned in the docs.

I searched further yet could not find anything like launch() so far.

-- Thibaut
 
A

Aldric Giacomoni

Thibaut said:
hum -- not sure actually. Is system() supposed to raise a NameError ?
I didn't see this mentioned in the docs.

I searched further yet could not find anything like launch() so far.

-- Thibaut
I have no idea.. I just started a shell, made up a command name which I
knew didn't exist, and waited to see what came back.
Reading your original post again, I think it's not quite what you want...
 
7

7stud --

Thibaut said:
hum -- not sure actually. Is system() supposed to raise a NameError ?
I didn't see this mentioned in the docs.

Easy enough to test:

begin
result = system("made up command")
puts result
rescue NameError => e
puts e
end

--output:--
false
 

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

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,966
Members
47,516
Latest member
ChrisHibbs

Latest Threads

Top