From: Sathvik La Date: 2009-12-26T05:42:40+09:00 Subject: Re: Dir.chdir does not work on windows (xp) Thank you for your replies. Yes the Ruby version says i386-mswin32 and when I used "c:\\Target\\tioga-1.11\\samples" I could chdir. I need to execute another program and parse the output. So I used IO.popen http://ruby-doc.org/core/classes/IO.html pdflatex = "pdflatex" @save_dir = "figures_out" name = "red" syscmd = "cd #{@save_dir} & #{pdflatex} -interaction=nonstopmode #{name}.tex" puts syscmd IO::popen(syscmd, "r+") puts $? It does not work. pdflatex complains Invalid Argument. However when I replace IO::popen(syscmd, "r+") with system(syscmd) it does work but I cannot read the output back. Can you please tell me why does this happen OR a workaround to achieve my goal. ==================================================== Here is the actual code @measures = {} IO::popen(syscmd, "r+") do |f| #puts $? f.close_write # We don't need that. log = File.open(logname, "w") for line in f log.print line if line =~ /^(.*)\[(\d)\]=(.+pt)/ n = $1 num = $2.to_i dim = Utils::tex_dimension_to_bp($3) @measures[n] ||= [] @measures[n][num] = dim end end end -- Posted via http://www.ruby-forum.com/.