Lisp HUG Maillist Archive

Executing a shell command on Windows

Hi

On LWW, I have been playing around with Cygwin, CMD.EXE, 
SYS:CALL-SYSTEM-SHOWING-OUTPUT etc in order to execute the following

	cd foo; make

or

	cd foo; nmake

I keep getting errors and I can't get my head around the necessary 
incantation to make this work.

Does anybody have any ideas?

Thanks

Marco



--
Marco Antoniotti					http://bioinformatics.nyu.edu
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.


Re: Executing a shell command on Windows

On Tue, 9 Aug 2005 10:29:26 -0400, Marco Antoniotti <marcoxa@cs.nyu.edu> wrote:

> On LWW, I have been playing around with Cygwin, CMD.EXE,
> SYS:CALL-SYSTEM-SHOWING-OUTPUT etc in order to execute the following
>
> 	cd foo; make
>
> or
>
> 	cd foo; nmake
>
> I keep getting errors and I can't get my head around the necessary
> incantation to make this work.
>
> Does anybody have any ideas?

On my system (WinXP, Cygwin installed, PATH environment variable set
accordingly) I wrote the following function which seems to work for
me:

  (defun run-program (command where)
    (let ((old-dir (get-working-directory)))
      (unwind-protect
          (progn
            (change-directory where)
            (with-open-stream
                (shell (sys:open-pipe nil :direction :io))
              (write-line command shell)
              (force-output shell)
              (write-line "exit" shell)
              (force-output shell)))
        (change-directory old-dir))))

For example: (run-program "make clean" "c:/home/lisp/foo/").

Cheers,
Edi.

PS: Or maybe you can execute something like

      "bash -c \"cd ~/foo; make clean\""


Re: Executing a shell command on Windows

Unable to parse email body. Email id is 4330

Re: Executing a shell command on Windows

Thanks but this will not do.  I am looking for a way to have an 
underlying shell execute a line.

Suppose I want

	cd foo; dosomething; cd /tmp/bar; dosomethingelse

the :CURRENT-DIRECTORY arg will not do.

I understand the above is contrived, but that's how things are.

Cheers

Marco


On Aug 9, 2005, at 11:49 AM, Martin Simmons wrote:

>>>>>> On Tue, 9 Aug 2005 10:29:26 -0400, Marco Antoniotti 
>>>>>> <marcoxa@cs.nyu.edu> said:
>
>   Marco> On LWW, I have been playing around with Cygwin, CMD.EXE,
>   Marco> SYS:CALL-SYSTEM-SHOWING-OUTPUT etc in order to execute the 
> following
>
>   Marco> 	cd foo; make
>
>   Marco> or
>
>   Marco> 	cd foo; nmake
>
>   Marco> I keep getting errors and I can't get my head around the 
> necessary
>   Marco> incantation to make this work.
>
>   Marco> Does anybody have any ideas?
>
> Check out the :CURRENT-DIRECTORY argument to 
> SYS:CALL-SYSTEM-SHOWING-OUTPUT.
>
> -- 
> Martin Simmons                              Email: martin@lispworks.com
> LispWorks Ltd, St John's Innovation Centre    TEL:   +44 1223 421860
> Cowley Road, Cambridge CB4 0WS, England.      FAX:   +44 870 2206189
>
--
Marco Antoniotti					http://bioinformatics.nyu.edu
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.


Re: Executing a shell command on Windows

Unable to parse email body. Email id is 4334

Re: Executing a shell command on Windows

tarvydas <tarvydas@allstream.net> writes:

> On August 9, 2005 12:37 pm, Marco Antoniotti wrote:
>> Suppose I want
>>
>> 	cd foo; dosomething; cd /tmp/bar; dosomethingelse
>
> This is a Windows problem, not a lisp problem.  You can't do this in windows - 
> there is no ';' (concatenate command) operator in windows like there is in 
> unix, e.g.


Actually, there is.  The  '&'  character does this.

If you run the NT command line processor CMD.COM and pass it commands
separated by &, it might work.


Re: Executing a shell command on Windows

At 9/08/2005 16:29, Marco Antoniotti wrote:
>Hi
>
>On LWW, I have been playing around with Cygwin, CMD.EXE, 
>SYS:CALL-SYSTEM-SHOWING-OUTPUT etc in order to execute the following
>
>         cd foo; make
>
>or
>
>         cd foo; nmake
>
>I keep getting errors and I can't get my head around the 
>necessary incantation to make this work.
>
>Does anybody have any ideas?

Hello,

Maybe the easiest way: write and test your procedure first (.bat 
file) and then call sys:open-pipe like in this example of a 
procedure with 1 argument, excerpt from my application:

(with-open-stream
       (s (sys:open-pipe "g:/pe/start-server.bat foil-server-only"))
     (loop while
           (print (read-line s nil nil))))

Print calls to display possible outputs from the procedure.

Francis


>Thanks
>
>Marco
>
>
>
>--
>Marco Antoniotti                                        http://bioinformatics.nyu.edu
>NYU Courant Bioinformatics Group                tel. +1 - 212 - 998 3488
>715 Broadway 10th FL                            fax. +1 - 212 - 998 3484
>New York, NY, 10003, U.S.A.
>
>


Updated at: 2020-12-10 08:51 UTC