Cygwin - batch file

View: New views
7 Messages — Rating Filter:   Alert me  

Cygwin - batch file

by _alpine_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everybody,

i'm trying to write a batch file, which open cygwin, automatically execute a script in cygwin, and then close cygwin.


can somebody help me please?



Re: Cygwin - batch file

by Mirco Piccin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

> i'm trying to write a batch file, which open cygwin, automatically execute a
> script in cygwin, and then close cygwin.

as reported in a my old post, that's what i've done: i've created a
file .bat (example: run_command.bat) on my desktop and inside that
(supposing you install cygwin in your C: drive):

C:

chdir C:\cygwin\bin


bash --login -i -c '<here insert the command you want to run>'


Save & Exit this file.
(obviously replace the  <here insert the command you want to run>
string with your command)
Now you need only to double-click in your .bat file.

Regards
M

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Cygwin - batch file

by _alpine_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hey,

thank u for the quick answer.
it works perfect, but i have to give the cygwin script under C:\Documents and Settings\user myscript.ksh!

how can i make it to have a directory, for eg C:\mybatchconversion where all files are there?

Re: Cygwin - batch file

by Mirco Piccin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry but my english is quite poor, so i don't understand well your question.
So, correct me if i'm going wrong.

> it works perfect, but i have to give the cygwin script under C:\Documents
> and Settings\user myscript.ksh!
>
> how can i make it to have a directory, for eg C:\mybatchconversion where all
> files are there?

You want to run with cygwin a .ksh file stored in  "C:\Documents and
Settings\user" ?
Well, in cygwin the system drive are mapped in this way :

$ mount
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
c: on /cygdrive/c type system (binmode,noumount)

...so i can do:
$ cd /cygdrive/c/Documents\ and\ Settings/<user>/
...to switch to Win <user> home directory.

I recommend to soft link your Windows home directory (C:\Documents and
Settings\<user>) to the linux home folder (/home/<user>) in this way:

$ mv /home/<user>/  /home/<user>.old/
(move the original folder to another)

$ ln -s /cygdrive/c/Documents and Settings/<user>  /home/<user>
(link the Win home dir to cygwin linux home dir)

$ cp -R /home/<user>.old/ *  /home/<user>/.
(right to have the .profile .bash* file)

In this way, cd to /home/<user>  and you will find yourself in your
Win home dir.

Of course, you can soft link any other path.
Remeber only that the Windows C: drive in cygwin environment is /cygdrive/c/.

So, coming back to our .bat file:

....
bash --login -i -c '/cygdrive/c/Documents and Settings/<user>/script.ksh'
...

-or, if you soft link Win home dir to /home/<user>:
...
bash --login -i -c '/home/<user>/script.ksh'
...

Hope i understand well :-D
M

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Cygwin - batch file

by _alpine_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i understand a little bit your answer but it dont works right now!

my start.bat is in the folder C:\batch

when i call start.bat , cygwin automatically goes into the folder C:\Documents and Settings\user .
so myscript.ksh file must be in C:\Documents and Settings\user.

i want to have myscript.ksh file in the C:\batch folder!
do u understand what i mean?

and i only can start my script with ./myscript.ksh

it should looks like this:

>>
C:

chdir C:\cygwin\bin

bash --login -i -c 'c:/batch./myscript.ksh'
<<

Re: Cygwin - batch file

by Larry Hall (Cygwin) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

_alpine_ wrote:

> i understand a little bit your answer but it dont works right now!
>
> my start.bat is in the folder C:\batch
>
> when i call start.bat , cygwin automatically goes into the folder
> C:\Documents and Settings\user .
> so myscript.ksh file must be in C:\Documents and Settings\user.
>
> i want to have myscript.ksh file in the C:\batch folder!
> do u understand what i mean?
>
> and i only can start my script with ./myscript.ksh
>
> it should looks like this:
>
> C:
>
> chdir C:\cygwin\bin
>
> bash --login -i -c 'c:/batch./myscript.ksh'
> <<
>

I think you want this then:

C:

chdir c:\batch

c:\cygwin\bin\bash -c './myscript.ksh'

You can add the '-i' if your script requires it for some reason.

--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Cygwin - batch file

by Mirco Piccin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

> my start.bat is in the folder C:\batch
 ok

> when i call start.bat , cygwin automatically goes into the folder
> C:\Documents and Settings\user .

cygwin goes there because that is your home folder.

> so myscript.ksh file must be in C:\Documents and Settings\user.
> i want to have myscript.ksh file in the C:\batch folder!

> do u understand what i mean?
now perfectly :-D

You can do simply:

C:

chdir C:\cygwin\bin

bash --login -c '/cygdrive/c/batch./myscript.ksh'

or as Larry recommend.
I sincerely prefer to use the "--login" option, but with this option
cygwin (linux) chdir to your home directory, of course.

Regards
M

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/