1 #!/usr/local/bin/ruby -w
5 # Copyright:: Copyright (C) 2006-2008 Christian M. Zmasek
6 # License:: GNU Lesser General Public License (LGPL)
8 # $Id: rb_qsub.rb,v 1.6 2008/08/30 19:57:59 cmzmasek Exp $
10 # last modified: 11/13/2007
13 # To execute qsub commands.
14 # Each line l (unless precded by a # or space) in file
15 # 'commands.qsub' is executed as 'qsub l'
18 module ForesterScripts
20 if RUBY_VERSION !~ /1.9/
21 puts( "Your ruby version is #{RUBY_VERSION}, expected 1.9.x " )
25 CMDS_FILE = 'commands.qsub'
26 TMP_CMD_FILE = '__QSUB_RB_CMD__'
29 if ( !File.exists?( CMDS_FILE ) )
30 puts( '[' +PRG_NAME + '] > commands file "' + CMDS_FILE + '" not found' )
34 puts( '[' +PRG_NAME + '] > reading ' + CMDS_FILE )
36 open( CMDS_FILE ).each { |line|
37 if ( line.length > 1 && line =~ /^[^#]\S+/ )
38 if ( File.exists?( TMP_CMD_FILE ) )
39 File.delete( TMP_CMD_FILE )
41 open( TMP_CMD_FILE, 'w' ) do |f|
44 puts( '[' +PRG_NAME + '] > excuting ' + line )
45 IO.popen( 'qsub ' + TMP_CMD_FILE , 'r+' ) do |pipe|
49 if ( File.exists?( TMP_CMD_FILE ) )
50 File.delete( TMP_CMD_FILE )
55 puts( '[' +PRG_NAME + '] > OK.' )