Re: SPAWN and strings [message #73364] |
Fri, 05 November 2010 08:45 |
Ludo
Messages: 7 Registered: May 2008
|
Junior Member |
|
|
I'm guilty !
kBob your explanation is in the IDL Help :
<<
If your SPAWN command contains a directory name with spaces and you
are using the < or > redirect tokens in a DOS window, you may receive
an error. If so, you can create a temporary environment variable
containing the command as follows:
setenv, 'MYARG="C:\test dir\ins" < "C:\test dir\refs" > ^
"C:\test dir\outs"'
SPAWN, '%MYARG%'
>>
|
|
|
Re: SPAWN and strings [message #73367 is a reply to message #73364] |
Fri, 05 November 2010 08:37  |
Ludo
Messages: 7 Registered: May 2008
|
Junior Member |
|
|
On 5 nov, 15:53, Heinz Stege <public.215....@arcor.de> wrote:
> Does it work, to write the 2nd filename without any quotes:
> SPAWN,'"C:\Program Files\myDir\myProg.exe" C:\directory name with
> spaces\myFile.h5'
>
> On my windows
> spawn,'"C:\Program Files\IrfanView\i_view32.exe" D:\my dir\my
> photo.jpg'
> is working.
No, I already tried. That's because the program I use (HDFView) is
expecting 0, 1 or more arguments, each one separated by a space. In
your case it would try to open 3 files :
D:\my
dir\my
photo.jpg
So we have on one hand a valid IDL string (I can compile a routine
containing it and print it). On the other hand exactly the same
command can be used manually in Windows shell (cmd.exe) using copy/
paste.
BUT using it as argument in SPAWN causes malfunctions with double-
quotes ( " ).
As I said earlier, using the /NOSHELL keyword (thereby bypassing the
use of a shell, see IDL Help) solved the issue.
Anyway, thanks for your help !
|
|
|
Re: SPAWN and strings [message #73372 is a reply to message #73367] |
Fri, 05 November 2010 07:53  |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Fri, 5 Nov 2010 03:49:53 -0700 (PDT), Ludo wrote:
> I'm running IDL 7.1 on Windows XP SP2
> I tried this in the command line (cmd.exe) :
>
>> "C:\Program Files\myDir\myProg.exe" "C:\directory name with spaces\myFile.h5"
>
> It works.
>
> When I try the same command with SPAWN, it doesn't work. (I put spaces
> around ' and " for an easy reading, in my command there aren't any
> spaces.)
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" "C:\directory name with
> spaces\myFile.h5" '
>
> It tries to lauch C:\Program, just like there weren't any quotes
> ( " ). I have the impression that SPAWN can't handle more than two "
> in a string. Why ?
>
> As expected, if my working directory is "C:\directory name with
> spaces", the following instruction works perfectly :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" myFile.h5'
>
> This one fails :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" "myFile.h5" '
>
> Did I miss something ? Some trick in strings management ?
>
Does it work, to write the 2nd filename without any quotes:
SPAWN,'"C:\Program Files\myDir\myProg.exe" C:\directory name with
spaces\myFile.h5'
On my windows
spawn,'"C:\Program Files\IrfanView\i_view32.exe" D:\my dir\my
photo.jpg'
is working.
Can't eyplain why. It is windows. ;-)
HTH, Heinz
|
|
|
Re: SPAWN and strings [message #73373 is a reply to message #73372] |
Fri, 05 November 2010 07:46  |
KRDean
Messages: 69 Registered: July 2006
|
Member |
|
|
On Nov 5, 4:49 am, Ludo <lu...@orange.fr> wrote:
> I'm running IDL 7.1 on Windows XP SP2
> I tried this in the command line (cmd.exe) :
>
>> "C:\Program Files\myDir\myProg.exe" "C:\directory name with spaces\myFile.h5"
>
> It works.
>
> When I try the same command with SPAWN, it doesn't work. (I put spaces
> around ' and " for an easy reading, in my command there aren't any
> spaces.)
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" "C:\directory name with
> spaces\myFile.h5" '
>
> It tries to lauch C:\Program, just like there weren't any quotes
> ( " ). I have the impression that SPAWN can't handle more than two "
> in a string. Why ?
>
> As expected, if my working directory is "C:\directory name with
> spaces", the following instruction works perfectly :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" myFile.h5'
>
> This one fails :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" "myFile.h5" '
>
> Did I miss something ? Some trick in strings management ?
Actually, it is an Environment Variable trick. I found this tip in
ITTVIS Tech tip. However, I forgot the Tip #.
Anyway, it works for me getting into the Windows XP UserProfile (C:
\Documents and Settings\kdean)
env = 'CMDUSERPROFILE=' + '"' + GETENV('USERPROFILE') + '\"'
SETENV, env
cmd = '%cmduserprofile%apps\PuTTY\Plink -ssh -v -batch ' +
runtime_machine + ' -l ' + username + ' ls -la'
SPAWN, CMD, listing, EXIT_STATUS = errOut, /STDERR, /LOG_OUTPUT
Kelly Dean
Milliken, CO
|
|
|
Re: SPAWN and strings [message #73374 is a reply to message #73373] |
Fri, 05 November 2010 07:45  |
Ludo
Messages: 7 Registered: May 2008
|
Junior Member |
|
|
>
> In IDL, this is a mis-formed command:
>
> IDL> a = "head" "waters"
>
Indeed, but this one is correct :
IDL> a = ' "head" "waters" '
It is a string containing several ".
By the way, adding the /NOSHELL keyword solved the problem.
|
|
|
Re: SPAWN and strings [message #73375 is a reply to message #73374] |
Fri, 05 November 2010 07:22  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ludo writes:
> As expected, if my working directory is "C:\directory name with
> spaces", the following instruction works perfectly :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" myFile.h5'
>
> This one fails :
>
> SPAWN, ' "C:\Program Files\myDir\myProg.exe" "myFile.h5" '
>
> Did I miss something ? Some trick in strings management ?
In IDL, this is a mis-formed command:
IDL> a = "head" "waters"
That's why your last command fails, I think. A valid
string can't be formed.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|