tags:

views:

219

answers:

1

Hey all,
I'm converting an xls 2 csv with a system(command) in ruby.
After the conversion i'm processing this csv files.
But the conversion is still going when the program wants to process the files. So at that time they are non existant.
Can someone tell me if it's possible to let Ruby wait the right amount of time for the system command to finish?
Right now i'm using sleep 20 but if it will take longer once, it isn't right of course... Thanks!

What I do specifically is this:

#Call on the program to convert xls
command = "C:/Development/Tools/xls2csv/xls2csv.exe C:/TDLINK/file1.xls"
system(command)
do_stuff

def do_stuff
#This is where i use file1.csv, however, it isn't here yet
end
A: 

Try to use threads:

command = Thread.new do
  system('ruby programm.rb') # long-long programm
end
command.join                 # main programm waiting for thread
puts "command complete"
TweeKane
How is using a secondary thread different from using the system command in the main thread? If the system command runs asynchronously in the main thread it will also in the secondary thread. So the join would finish immediatly while the system command is still running.
Aurril