views:

658

answers:

3

Dear all,

I have the following way to submit a job with cluster using qsub:

 Submitting jobs from standard input
       To submit a PBS job by typing job specifications at the command line, the user types

              qsub [options] <return>

       then types any directives, then any tasks, followed by

              (in UNIX)     CTRL-D on a line by itself
              (in Windows)  CTRL-Z <return>

       to terminate the input.

Is there a way we can encode RETURN and CTRL-D in bash script so that we can do something like:

for i in path/*.txt; do echo "$i";  qsub [RETURN] /path2/mycode $i; [CTRL-D]; done
+1  A: 

Try echo /path2/mycode $i | qsub.

If this won't work or you need to pass more complex data, then expect may help.

Eugene Morozov
+4  A: 

You should use redirection through pipes:

for i in path/*.txt; do
  echo "$i";
  echo "/path2/mycode $i" | qsub;
done
corvus
+1  A: 

Just for clarification (since corvus's answer is exactly right) - CTRL-D just means "end of file" or "end of input", so when you echo that text to qsub, it will then automatically send an end-of-file signal afterwards (which is the same as pressing CTRL-D)

Jesse Rusak