If the user specifies a batch script to an interactive job, the old behavior was to parse the script for #PBS directives but otherwise ignore the contents. With this patch, the script is run inside a shell connected to the terminal, allowing the user to see the output and provide interactive input to the script. Patch by Michal Kouril of ECECS at University of Cincinnati. --- pbs-2.3.12/doc/man1/qsub.1B | 8 ++++++-- pbs-2.3.12/src/resmom/start_exec.c | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff -puN src/resmom/start_exec.c~interactive-with-script src/resmom/start_exec.c --- pbs-2.3.12-orig/src/resmom/start_exec.c~interactive-with-script 2004-07-16 09:41:52.000000000 -0400 +++ pbs-2.3.12/src/resmom/start_exec.c 2004-07-16 09:52:38.000000000 -0400 @@ -1359,18 +1359,30 @@ finish_exec(pjob) arg[0] = malloc(strlen(shellname) + 2); strcpy(arg[0], "-"); strcat(arg[0], shellname); + arg[1] = 0; #if SHELL_USE_ARGV == 1 - if (!is_interactive) { + /* + * Two cases: + * non-interactive: better be a script, run it. + * interactive: optional script, if so run it + * (although connected to tty), else just exec + * the shell + */ + { + struct stat st; arg[1] = malloc(strlen(path_jobs) + strlen(pjob->ji_qs.ji_fileprefix) + strlen(JOB_SCRIPT_SUFFIX) + 1); strcpy(arg[1], path_jobs); strcat(arg[1], pjob->ji_qs.ji_fileprefix); strcat(arg[1], JOB_SCRIPT_SUFFIX); - arg[2] = (char *)0; - } else + arg[2] = 0; + if (stat(arg[1], &st) != 0) { + free(arg[1]); + arg[1] = 0; + } + } #endif - arg[1] = (char *)0; execve(shell, arg, vtable.v_envp); } else if (cpid == 0) { /* child does demux */ diff -puN doc/man1/qsub.1B~interactive-with-script doc/man1/qsub.1B --- pbs-2.3.12-orig/doc/man1/qsub.1B~interactive-with-script 2004-07-16 09:51:39.000000000 -0400 +++ pbs-2.3.12/doc/man1/qsub.1B 2004-07-16 09:56:34.000000000 -0400 @@ -1138,8 +1138,12 @@ option is specified on the command line the "interactive" job attribute declared true via the \-W option, .Ty "-W interactive=true" , either on the command line or in a script directive, the job is an interactive -job. The script will be processed for directives, but will not be included -with the job. When the job begins execution, all input to the job is from +job. If a script is specified, it will be processed for directives and +the job will run the contents of the script. (Note that you might find +it useful to invoke a shell within the script for debugging or to execute +arbitrary commands after the script finishes.) If no script is specified, +the user's shell is started. +When the job begins execution, all input and output goes to the terminal session in which qsub is running. .LP When an interactive job is submitted, the qsub command will not _