× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Jim,

Put double quotes around your variables. (It *must* be double quotes, single quotes won't work.)

cd "$3"
jar cMf "$2" "$1"

The double-quotes will cause the spaces to be treated as part of the filename.


Another thing to consider... Unlike CL, Qshell will NOT stop if it encounters an error. (At least, not by default.) In your example, if the cd command fails, it'll still run the jar command -- but you'll be in the wrong directory when it runs.

To solve that, I'd change your script to look like this:

cd "$3" || exit 1
jar cMf "$2" "$1" || exit 1

The || means "only if the preceding command failed". So if the cd command fails, it'll run the exit command, and the exit command will terminate your script with an exit status of 1 (which can be detected in the CL.) Likewise, if the jar command fails, it'll exit with 1, and you can detect the exit status of 1 in the CL program.

Good luck


Jim Essinger wrote:
Qshell gurus,

I am running a script that has the following commands;

cd $3
jar cfM $2 $1

i am using the following CL command to execute the script;

QSH CMD(&COMMAND)

The variable command contains this value;

/QShell/scriptname.qsh "File_Name.txt" "/ftp/Path Name/File_Name.txt.zip"
"/tmp"

The intent is that the script will change the directory to "/tmp" and then
the jar utility will place "File_Name.txt" into a compressed archive file
called "File_Name.txt.zip" in the subdirectory of "/ftp" called "/Path
Name".

What I get is a archive file named "Path" in the subdirectory "/ftp".

Question is - how can I get the jar command in the script to recognize that
"/ftp/Path Name" is a path, ignoring the white space? I am trying to get
the utliity that I am writing to support path names that may include those
white spaces. Any thought or suggestions? I have tried no quotes, single
quotes and double quotes for the three parms being passed to the script.

Thanks!

Jim


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.