diff --git a/testsuite/expect/test17.5 b/testsuite/expect/test17.5
index 74ae4132969245c182e327a2edff2ae8b6813af6..e8a72451a45515991113789eab6bf0c9d5449162 100755
--- a/testsuite/expect/test17.5
+++ b/testsuite/expect/test17.5
@@ -34,6 +34,7 @@ source ./globals
 
 set test_id     "17.5"
 set file_in     "test$test_id.input"
+set file_script "test$test_id.bash"
 set file_out    "test$test_id.output"
 set file_err    "test$test_id.error"
 set file_out_j  "test$test_id.j.%j.output"
@@ -46,13 +47,66 @@ print_header $test_id
 # Delete left-over stdin/out/err files
 # Build stdin file
 #
-exec $bin_rm -f $file_in $file_out $file_err
+exec $bin_rm -f $file_in $file_script $file_out $file_err
 make_bash_script $file_in "
   $bin_id
   $bin_sleep aaa
   exit 0
 "
 
+set cwd "[$bin_pwd]"
+make_bash_script $file_script "
+  cd /tmp
+  $sbatch -N1 --workdir=$cwd --output=$file_out --error=$file_err -t1 $cwd/$file_in
+  exit 0
+"
+
+#
+# Spawn a shell via sbatch that submits from a different directory and uses stdout/err 
+# and confirm their contents
+#
+set job_id 0
+spawn $file_script
+expect {
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sbatch not responding\n"
+		set exit_code 1
+		exp_continue
+	}
+	eof {
+		wait
+	}
+}
+if { $job_id == 0 } {
+	send_user "\nFAILURE: failed to submit job\n"
+	exit 1
+}
+
+#
+# Wait for job to complete
+#
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
+	set exit_code 1
+}
+
+#
+# Check for desired output
+#
+if {[wait_for_file $file_out] != 0} {
+	send_user "\nFAILURE: Missing stdout\n"
+	set exit_code 1
+}
+if {[wait_for_file $file_err] != 0} {
+	send_user "\nFAILURE: Missing stderr\n"
+	set exit_code 1
+}
+exec $bin_rm -f $file_script $file_out $file_err
+
 #
 # Spawn a shell via sbatch that uses stdout/err and confirm their contents
 #
@@ -227,7 +281,7 @@ if { [file exists $file_err2] } {
 }
  
 if {$exit_code == 0} {
-	exec $bin_rm -f $file_in $file_out $file_err
+	exec $bin_rm -f $file_in $file_script $file_out $file_err
 	send_user "\nSUCCESS\n"
 }
 exit $exit_code