diff --git a/pbatch/pb.rb b/pbatch/pb.rb index 70029d6..55d7e59 100755 --- a/pbatch/pb.rb +++ b/pbatch/pb.rb @@ -39,20 +39,22 @@ ENDTXT end def readconfig - File.open("#{@basedir}/#{CONFIG}").each_line {|line| - line.sub!(/#.*/, "") - line.sub!(/^\s*/, "") - line.sub!(/\s*$/, "") - if line.match(/^$/) - next - end - line.match(/([^=]*?)\s*=\s*(.*)/) - case $1 - when "maxproc" then @config["maxproc"] = $2 - when "waittime" then @config["waittime"] = $2 - else puts "unknown option #{$1}" - end - } + if FileTest.exists?("#{@basedir}/#{CONFIG}") + File.open("#{@basedir}/#{CONFIG}").each_line {|line| + line.sub!(/#.*/, "") + line.sub!(/^\s*/, "") + line.sub!(/\s*$/, "") + if line.match(/^$/) + next + end + line.match(/([^=]*?)\s*=\s*(.*)/) + case $1 + when "maxproc" then @config["maxproc"] = $2 + when "waittime" then @config["waittime"] = $2 + else puts "unknown option #{$1}" + end + } + end end def status @@ -111,7 +113,7 @@ def addjob puts "Job #{jobnumber} already scheduled. This should not happen." exit end - File.open("#{@basedir}/#{JOBSDIR}/#{jobnumber}"){|file| + File.open("#{@basedir}/#{JOBSDIR}/#{jobnumber}", "w"){|file| file.puts ARGV.join(" ") } File.chmod(RUNMODE, "#{@basedir}/#{JOBSDIR}/#{jobnumber}") @@ -136,7 +138,7 @@ end def createconfig if ! FileTest.exists?("#{@basedir}/#{CONFIG}") - File.new("#{@basedir}/#{CONFIG}", "w"){|file| + File.open("#{@basedir}/#{CONFIG}", "w"){|file| file.puts <