0

On windows XP, I have a bat file which calls a perl script, which itself shall contain a "make" command in a cygwin context. (I can't change this BAT -> PERL -> CYGWIN structure). This works a little bit but I don't find how to exit from the cygwin environment.

For example, in my perl script, this line seems to work :

 print STDOUT "START PERL SCRIPT\n" ;
system ("$ENV{CYGWIN_HOME}\\bin\\bash | $ENV{CYGWIN_HOME}\\bin\\make -version");
print STDOUT "END OF PERL SCRIPT\n" ;

However, in my cmd.exe, this is my output:

  • START PERL SCRIPT
  • GNU Make 3.80 Copyright (C) 2002 Free Software Foundation, Inc.
  • This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • bash-3.2$

My problem is that I stay in bash environment : the line "bash-3.2$" still waits for a command, and I cant' find a solution to exit automatically from it (the only way is to manually print "exit" in cmd.exe). My perl script is thus stopped instead of automatically continuing its jobs.

I've not succeeded with solutions such as "Using perl to run more than one system command in a row"

Do you know how to write the perl script and commands in order to get out of the bash environment and continue the perl script ?

Thanks a lot, Calim


Update

So finally I have moved to another solution. It seems to work (i.e. I go back to my perl script after the shell command is executed) ; I just hope there will be no unexpected effect. Do you have any opinion about it ?

print STDOUT "START PERL SCRIPT\n";
open ( CYGWIN , "|-" , "$ENV{CYGWIN_HOME}\\bin\\bash" ) ;
print CYGWIN "$ENV{CYGWIN_HOME}\\bin\\make -w -C /cygdrive/c/tmp/Generation makefile" ;
close CYGWIN ;
print STDOUT "END OF PERL SCRIPT\n";
2
  • 1
    You are trying to run what is essentially bash | make, why? What are you trying to achieve? Commented Sep 25, 2014 at 9:41
  • Currently, someone manually opens cygwin (on windows XP) and starts the make command (bin\make.exe) with a makefile he has written himself. I have to realize a perl script which performs this make, but with many checks before and after the make command. I don't know whether I'am clear in my explanations ... Commented Sep 25, 2014 at 10:12

2 Answers 2

2

Why are you piping the ouptut of bash to make?!?!?!

system("$ENV{CYGWIN_HOME}\\bin\\make -version");

Or maybe you need some environment variables set up by bash.

system("$ENV{CYGWIN_HOME}\\bin\\bash -c 'make -version'");
answered Sep 25, 2014 at 14:05
Sign up to request clarification or add additional context in comments.

Comments

-2

So finally I have moved to another solution. It seems to work (i.e. I go back to my perl script after the shell command is executed) ; I just hope there will be no unexpected effect. Do you have any opinion about it ?

print STDOUT "START PERL SCRIPT\n";
open ( CYGWIN , "|-" , "$ENV{CYGWIN_HOME}\\bin\\bash" ) ;
print CYGWIN "$ENV{CYGWIN_HOME}\\bin\\make -w -C /cygdrive/c/tmp/Generation makefile" ;
close CYGWIN ;
print STDOUT "END OF PERL SCRIPT\n";
answered Sep 25, 2014 at 13:38

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.