BH=Bill, OK=Oleg

BH> |       WriteFile y;x;(#x);(sint 0);0
BH> | |domain error: cd
BH> | |cd[:0]
 
OK> It tries to write to child stdin a boxed list of args?

Oleg's analysis is correct.  I provided a faulty version of bash.  Remove the  
~  from the definition.  Try it now, it should
work.

OK>    cd \ & dir

In my personal experience, simple &-chains like this are fine, but the more 
complex things you do, the more "&" intrudes and
causes problems.  Also, I start running into line-length problems.  And, since 
CreateProcess already provides as WorkingDirectory
parameter, why not use it?

Bill:  I think some of your problems are caused by lack of knowledge of how 
commands are interpreted. 

You should first understand that quotes are used to keep elements atomic.  That 
is, since the command interpreter cuts on spaces
by default, and treats each cut like a separate part of the command, we need a 
way to say "ignore the spaces within this part; it
is a unified whole".

So, for example, cmd.exe expects the first part of the command to be the 
filename of the executable to run.     But what is the
first part of the command?

In  

    C:\>  C:\Program Files\Some Directory\foo.exe  parameter c:\filename 
containing spaces

Since cmd.exe cuts on spaces by default, the first part of that command is 
"C:\Program".  And, since "C:\Program" isn’t the name
of a executable, the interpreter complains.  If you were to create a dummy 
executable, name it Program.exe, put it at C:\, and
re-run the command, you would see Program.exe would be invoked.

In

   C:\>  "C:\Program Files\Some Directory\foo.exe parameter"  c:\filename 
containing spaces

The first part is "C:\Program Files\Some Directory\foo.exe parameter", which 
again isn’t the name of an executable file.  What you
want is something like:

  C:\>  "C:\Program Files\Some Directory\foo.exe"  parameter c:\filename 
containing spaces

except for one thing:  the command interpreter is AGAIN going to cut on spaces 
by default, and therefore pass four parameters
foo.exe:  "parameter", "C:\filename", "containing", and "spaces".  What you 
intended and and foo.exe expected were that two
parameters be passed:  "parameter" and "c:\filename containing spaces".

Again, to inform the interpreter that despite the embedded spaces, the file 
parameter is a single indivisible unit, you need to
surround it with quotes:

  C:\>  "C:\Program Files\Some Directory\foo.exe"  parameter "c:\filename 
containing spaces"

This is what you want and will work.  

Remember that you need to do this for each parameter which contains spaces.  
Or, for that matter, any character that the
interpreter considers special (like &).  

I should note that the bash command interpreter gives you other ways to escape 
spaces and other special characters, but you might
then be better off googling for an extensive command line tutorial.

-Dan


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to