From: Albert Schlef on 7 Apr 2010 00:55 Hi! I want to launch a program and I don't care about its return value or output. I also don't want it to block my ruby program. On Linux I do this as follows: if !fork system("xpdf /path/to/some/file") exit! # ... or exec() ... end But it doesn't work on MS-Windows... it complains that fork() isn't implemented. So how do I launch a program on MS-Windows without it blocking me and without caring about its output and return status? -- Posted via http://www.ruby-forum.com/.
From: Marvin Gülker on 7 Apr 2010 04:19 Albert Schlef wrote: > Hi! > > I want to launch a program and I don't care about its return value or > output. I also don't want it to block my ruby program. > > On Linux I do this as follows: > > if !fork > system("xpdf /path/to/some/file") > exit! > # ... or exec() ... > end > > But it doesn't work on MS-Windows... it complains that fork() isn't > implemented. > > So how do I launch a program on MS-Windows without it blocking me and > without caring about its output and return status? You may use the win32-process gem that implements #fork as far as I know, or simply IO.popen: -------------------------------- IO.popen("your command") #Just go on here -------------------------------- Marvin PS: On Linux I think the #spawn method does this task best. -- Posted via http://www.ruby-forum.com/.
From: Joel VanderWerf on 7 Apr 2010 11:23 Albert Schlef wrote: > Hi! > > I want to launch a program and I don't care about its return value or > output. I also don't want it to block my ruby program. > > On Linux I do this as follows: > > if !fork > system("xpdf /path/to/some/file") > exit! > # ... or exec() ... > end > > But it doesn't work on MS-Windows... it complains that fork() isn't > implemented. > > So how do I launch a program on MS-Windows without it blocking me and > without caring about its output and return status? Thread.new do system("...") end This works on windows as well as platforms with fork.
|
Pages: 1 Prev: pass a password to ssh Next: Parse the data in an array index in ruby |