diff --git a/src/common/xstring.c b/src/common/xstring.c
index 65bfe544fbb8f7368e06c037d4b57f61f7a9a75e..0393c50b0b43c895e5e0108a7fe4726c052ed2a8 100644
--- a/src/common/xstring.c
+++ b/src/common/xstring.c
@@ -43,6 +43,7 @@
 #endif
 
 #include <stdarg.h>
+#include <ctype.h>
 
 #include <slurm/slurm_errno.h>
 
@@ -69,6 +70,7 @@ strong_alias(xstrndup,		slurm_xstrndup);
 strong_alias(xbasename,		slurm_xbasename);
 strong_alias(_xstrsubstitute,   slurm_xstrsubstitute);
 strong_alias(xshort_hostname,   slurm_xshort_hostname);
+strong_alias(xstring_is_whitespace, slurm_xstring_is_whitespace);
 
 /*
  * Ensure that a string has enough space to add 'needed' characters.
@@ -341,3 +343,21 @@ char *xshort_hostname(void)
 
 	return xstrdup(path_name);
 }
+
+/* Returns true if all characters in a string are whitespace characters,
+ * otherwise returns false;
+ */
+bool xstring_is_whitespace(const char *str)
+{
+	int i, len;
+
+	len = strlen(str);
+	for (i = 0; i < len; i++) {
+		if (!isspace(str[i])) {
+			return false;
+		}
+	}
+
+	return true;
+}
+
diff --git a/src/common/xstring.h b/src/common/xstring.h
index d02c1d471a95ac6ae486d74239f15ec93efabeb5..941acadac80146536252ae0c852eae72b0d46509 100644
--- a/src/common/xstring.h
+++ b/src/common/xstring.h
@@ -113,4 +113,10 @@ void _xstrsubstitute(char **str, const char *pattern, const char *replacement);
  */
 char *xshort_hostname(void);
 
+/* 
+ * Return true if all characters in a string are whitespace characters,
+ * otherwise return false.  ("str" must be terminated by a null character)
+ */
+bool xstring_is_whitespace(const char *str);
+
 #endif /* !_XSTRING_H */
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index e1a87a88f483abfe0b1cc3a1312a55debb105e04..59b77b18c7ddd671e9a75d81dca13d490804a57b 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -529,24 +529,6 @@ _str_to_nodes(const char *num_str, char **leftover)
 	return (int)num;
 }
 
-/* Returns true if all characters in a string are whitespace characters,
- * otherwise returns false;
- */
-static bool
-_is_whitespace(const char *str)
-{
-	int i, len;
-
-	len = strlen(str);
-	for (i = 0; i < len; i++) {
-		if (!isspace(str[i])) {
-			return false;
-		}
-	}
-
-	return true;
-}
-
 /* 
  * verify that a node count in arg is of a known form (count or min-max)
  * OUT min, max specified minimum and maximum node counts
@@ -563,7 +545,7 @@ _verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
 	if ((ptr = index(arg, '-')) != NULL) {
 		min_str = xstrndup(arg, ptr-arg);
 		*min_nodes = _str_to_nodes(min_str, &leftover);
-		if (!_is_whitespace(leftover)) {
+		if (!xstring_is_whitespace(leftover)) {
 			error("\"%s\" is not a valid node count", min_str);
 			xfree(min_str);
 			return false;
@@ -574,7 +556,7 @@ _verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
 
 		max_str = xstrndup(ptr+1, strlen(arg)-((ptr+1)-arg));
 		*max_nodes = _str_to_nodes(max_str, &leftover);
-		if (!_is_whitespace(leftover)) {
+		if (!xstring_is_whitespace(leftover)) {
 			error("\"%s\" is not a valid node count", max_str);
 			xfree(max_str);
 			return false;
@@ -582,7 +564,7 @@ _verify_node_count(const char *arg, int *min_nodes, int *max_nodes)
 		xfree(max_str);
 	} else {
 		*min_nodes = *max_nodes = _str_to_nodes(arg, &leftover);
-		if (!_is_whitespace(leftover)) {
+		if (!xstring_is_whitespace(leftover)) {
 			error("\"%s\" is not a valid node count", arg);
 			return false;
 		}
diff --git a/src/sattach/opt.c b/src/sattach/opt.c
index efada62dbd9ad28b61014c4283f4d6c7fb88aab0..a537aa0bb995881e66cded0f282f3b6ed351b2bc 100644
--- a/src/sattach/opt.c
+++ b/src/sattach/opt.c
@@ -277,24 +277,6 @@ void set_options(const int argc, char **argv)
 	}
 }
 
-/* Returns true if all characters in a string are whitespace characters,
- * otherwise returns false;
- */
-static bool
-_is_whitespace(const char *str)
-{
-	int i, len;
-
-	len = strlen(str);
-	for (i = 0; i < len; i++) {
-		if (!isspace(str[i])) {
-			return false;
-		}
-	}
-
-	return true;
-}
-
 static void _parse_jobid_stepid(char *jobid_str)
 {
 	char *ptr, *job, *step;
@@ -314,7 +296,7 @@ static void _parse_jobid_stepid(char *jobid_str)
 	}
 
 	jobid = strtol(job, &ptr, 10);
-	if (!_is_whitespace(ptr)) {
+	if (!xstring_is_whitespace(ptr)) {
 		error("\"%s\" does not look like a jobid", job);
 		_usage();
 		xfree(job);
@@ -322,7 +304,7 @@ static void _parse_jobid_stepid(char *jobid_str)
 	}
 
 	stepid = strtol(step, &ptr, 10);
-	if (!_is_whitespace(ptr)) {
+	if (!xstring_is_whitespace(ptr)) {
 		error("\"%s\" does not look like a stepid", step);
 		_usage();
 		xfree(job);
diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 1b87f3c22a2d90f6ba3ce6f121a427f7fb71f089..08883c5ef6e093a5547252779f17446525b53a12 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -202,9 +202,15 @@ static char *xget_script_string(void)
 			error("Unable to open file %s", remote_argv[0]);
 			return NULL;
 		}
-	}	
+	}
 	script = script_from_stream(fs);
 	fclose(fs);
 
+	if (xstring_is_whitespace(script)) {
+		error("Batch script contains only whitespace!");
+		xfree(script);
+		return NULL;
+	}
+
 	return script;
 }