Launching C executable via ruby script on Ubuntu server -
i have situation need assistance with. involves ruby, rails, , native c applications running on ubuntu server.
i able compile c applications on server , need know how launch them via ruby script.
my end goal take lists of data rails app, save them specific .dat file on server, use file input executables (along flags), , load resulting files through ruby script rails app display.
i'm looking @ these start:
confirm existance of executable (script, bat, cmd, exe) via ruby file
launch script on separate server rails app
confirm existance of executable (script, bat, cmd, exe) via ruby file
ruby require_relative executing script?
if has done or has ideas of how please advise.
you can this
original_file_path = 'path/to/original_file.dat' modified_file_path = 'path/to/modified_file.dat' file.write(file_path, 'data') #this return output c program #use if need parse output c program result = `some_c_executable --some_flag #{file_path}` #parsing result... data = file.read(modified_file_path) #work data
or
#if don't need output c program, use "system" #it returns true or false according success result = system "some_c_executable --some_flag #{file_path}" if result data = file.read(modified_file_path) #work data else ... end
Comments
Post a Comment