X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Sep 2015 07:05 PM by  anon
spawn through cygwin
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Sep 2015 07:05 PM
    I have a Windows 7 computer running IDL 8.4 and have cygwin installed as a linux emulator. I want to send a command through to cygwin and have tried two things: spawn through cmd.exe which then calls cygwin to execute command spawn through cygwin to execute command I cannot get spawn to do anything, how do I set the shell to open cmd.exe? The command I want to pass works in both cygwin and the command line independently. I've tried SETENV,'SHELL=cmd.exe' SETENV,'SHELL=C:\\Windows\ system32\cmd.exe' SETENV,'SHELL=C:\cygwin64\bin\bash -c' as well as a few others. I cannot get the my command to execute using the spawn command. Please let me know exactly how to set up my environmental variable shell so I can get this to work, thanks!

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    09 Sep 2015 11:34 AM
    Hi Brita, First I should mention that defining a shell environment variable will not tell Windows what do do. This comes down to the way that cygwin runs. Unlike a normal Windows command prompt where you can type something like 'echo Command1&echo command2' to run two commands, if you do this with command one launching cygwin and the second command running your shell command then this will not happen. Instead only cygwin will be started and the second command is forgotten about. Because you can't do this in a normal command prompt, you will not be able to do this using SPAWN. However, I think that there is a workaround to create a script file with launches cygwin, runs a script in cygwin and then returns to the command prompt. This way the SPAWN command will actually return to IDL and you should have your result within IDL. Otherwise the command prompt with cygwin will be running and expecting input, which means IDL will wait until it is finished. I found the following web page which discusses how to launch cygwin, run a shell script, and provides an example: http://blog.dotsmart.net/...-scripts-on-windows/ Hope this helps!

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Sep 2015 12:42 PM
    Using the /log_output I can see that my command is being executed in cmd.exe. However, the command I am executing (directed to cygwin) requires opening another file which is located in the cygwin directory. From cmd.exe cd c:\cygwin64\home\bkirving c:\cygwin64\bin\bash -c "C:/cygwin64/home/bkirving/bin/dbd2asc C:/cygwin64/home/bkirving/dockserver_rsync/gliders/unit_191/from-glider/unit_191-2015-195-1-100.sbd > sbd_1.asc" this works just fine. I need to change the directory in cmd.exe then execute my command for it to work. Is there a way to change the directory then enter my command using spawn?

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    10 Sep 2015 10:34 AM
    Hi Brita, As I mentioned in my first post, you have to string together every command that you want to use on Windows with an ampersand (&) because the SPAWN command in IDL does not open a command prompt for multiple lines of commands to be sent to. On top of this, you cannot do something like the following in a Windows command prompt: C;\cygwin64> Cygwin.bat&echo "Second command is called" The above command was supposed to start cygwin throught the cygwin batch file and echo something to the now cygwin command prompt. The cygwin command prompt disregards the second command which means that you cannot use SPAWN to string multiple commands together within cygwin. This is why I included the link in my first post, which discusses how to create a windows batch file that starts cygwin, runs your command, and exits. This you can to in a command prompt as calling the batch file which will also work with SPAWN.
    You are not authorized to post a reply.