 |
 |
spaces giving problem on Mac OS.
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status:
Offline
|
|
hi,
i m opening applications on Mac OS thru the "open" command. But the
problem arises when any directory or file name contains spaces. For
example, if i have a folder named "My Folder", then any file in this
folder can not be opened through this command.
similar problem is there when file name contains spaces.
can anybody suggest, what could be the solution.
Please help. Its urgent.
Rachna
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Dec 2000
Location: Kirkland, WA, USA
Status:
Offline
|
|
Three ways to do it:
(1) Use quotation marks: open "My Folder"
(2) Use the backslash as an escape character: open My\ Folder
(3) type the first few letters then hit Tab: open My<TAB>
|
|
Dang! I forgot to uncheck the "Show Signature" button again!
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: mission, tx
Status:
Offline
|
|
single quotes works as well...
----
life is made up of moments...this is one of them
|
|
life is made up of moments...this is one of them
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status:
Offline
|
|
Thanx for ur prompt reply.
i have tried ur suggestions on the terminal, and they are working correctly.
but when i try to invoke the same command in Runtime.getRuntime().exec() method, it still does'nt work.
For Example i have tried:
suppose i want to open "System Folder"
Runtime.getRuntime().exec("open /System\\ Folder"); // for backslash
Runtime.getRuntime().exec("open \"/System Folder\""); // for double quotes
but none of these is working.
Please help.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: Netherlands
Status:
Offline
|
|
Originally posted by Rachna:
but when i try to invoke the same command in Runtime.getRuntime().exec() method, it still does'nt work.
For Example i have tried:
suppose i want to open "System Folder"
Runtime.getRuntime().exec("open /System\\ Folder"); // for backslash
Runtime.getRuntime().exec("open \"/System Folder\""); // for double quotes
Dive into the JAVA documentation.
I used this with one of my apps. http://xamba.sourceforge.net/xamba/Xamba1b3.sit
Download this app and look into the sourcefiles. It is used many times.
DJ
|

Derk-Jan Hartman, Student of the University Twente (NL), developer of VLC media player
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: Costa Luna, !*
Status:
Offline
|
|
try: Runtime.getRuntime().exec("open /System\ Folder");
a backslash is an escape sequence, which is used to express a character that can't be directly interpreted by the shell (or by the compiler, in the case of java) because it uses that character in another context. for example, the shell uses spaces to differentiate arguments on the command line. you need to either escape the space in your filename or you need to encase the filename in quotes. one or the other, but not both. but in java, you can't encase the filename in quotes because the compiler uses quotes to delineate strings and also because the exec function doesn't use quotes to qualify a filename (um, i think).
basically you need to understand the reasons for escaping different characters in the shell and in a string in java (or any other context where you need use an escape sequence).
ok, that rambled on a little, but uh, good luck.  and corrections welcome.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 1999
Location: Portland, Oregon
Status:
Offline
|
|
Originally posted by beeduul:
try: Runtime.getRuntime().exec("open /System\ Folder");
I believe he was using two \\ 's on purpose. For example, in PHP you use one \ as an escape character, or two \\'s if you actually want a \
I dont know java at all though (and I assume that is what this is based on comments?)

|
|
everything you know is wrong (and stupid)
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status:
Offline
|
|
I have not yet got any solution to the spaces problem. I have tried to do it through double quotes and backslashs , it works fine in terminal but it is not working in my java program. And my ultimate aim is to open the applications through the java programs. For this i m using open command.
what could be the solution.
Please help. Its urgent.
Thanx
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: London
Status:
Offline
|
|
Do some reading up on the sun webpage thay might be able to help also mail apple....
------------------
450DP/448MB/80GB/Rage/Apple 17"/Zip250/ZipCD/Epson740
ICQ 60617180
I Took The Red Pill
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Nov 2000
Location: New Yawk
Status:
Offline
|
|
Moving this to the OS X Developer forum. Click through to find yourself.
thanks
------------------
the oddball newsletter
------------------
it's only after you lose everything that you're free to do anything
The gem cannot be polished without friction, nor man perfected without trials.
|
|
"Do not be too positive about things. You may be in error." (C. F. Lawlor, The Mixicologist)
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status:
Offline
|
|
Try Runtime.exec(String[] cmdarray) instead, as in
String[] cmd = {"open", "/System Folder"};
Runtime.getRuntime().exec(cmd);
If the parameters need to be escaped, it should happen automatically.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status:
Offline
|
|
My problem has been solved at last.
The syntax which did the work is:
String cmd[] = {"open", "/System Folder"};
Runtime.getRuntime().exec(cmd);
thanx very much for all ur help.
Rachna
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|