I want to write a simple script that will check to see if a program is open every hour using the whenever gem. If that application is not open I want it to start up the application. I can't find out how to launch an application with Ruby. Pardon the ignorance. I am new.
            Asked
            
        
        
            Active
            
        
            Viewed 43 times
        
    2 Answers
1
            Run an application in various ways:
Kernel#system runs my_program in a subshell and returns true if the subshell exits successfully, false otherwise.
system("my_program")
Kernel#exec replaces the currently executing process with my_program.
exec("my_program")
%x() will run the program and return the output.
%x(my_program)
 
    
    
        Fred
        
- 8,582
- 1
- 21
- 27
0
            
            
        You can use the Kernal#system method like this:
system 'open -n /Applications/Appname.app'
With #system you'll get a return value of true or false, enabling you to do some flow control incase there's an issue (i.e. maybe the app doesn't exist in the system)
 
    
    
        Anthony
        
- 15,435
- 4
- 39
- 69
