LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-17-2008, 10:46 AM   #1
plasya777
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Rep: Reputation: 0
How to write a batch file for windows that starts cygwin tool and runs unix scripts


Hi,

I need to write a batch file for windows that automatically starts the cygwin tool in windows and executes the unix scripts.Previously we had these scripts in unix server.Now we need to migrate them to Windows server.For this reason we are using cygwin tool that allows the scripts to be executed on Windows server.We had written a batch file that starts the cygwin tool,but we were not able to execute the unix scripts.How can we write a batch file such that it executes all the unix scripts in cygwin.

Thanks,
Lasya
 
Old 11-17-2008, 05:24 PM   #2
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 87
IMHO, that won't work. cygwin operates almost like a virtual machine inside windows. DOS or CMD interprets command line interface in Windows, and interprets batch files the same way.

I'm no cygwin buff, but maybe if you setup a script to bootstrap your other scripts after cygwin starts? Look at this link for more information http://www.cs.wcupa.edu/~rkline/cygwin-install.html, right down the bottom of the page is something like this:

Quote:
Edit the main startup script, /Cygwin.bat, (which is c:\cygwin\Cygwin.bat). If you use nano from within the cygwin shell, type: (etc etc....)
Can you call your scripts from within Cygwin.bat? Be careful here, i'm not sure of the consequences. A reminder from another member here:

Before you do anything I tell you to, I presume you have a working verifiable backup!

Last edited by irishbitte; 11-17-2008 at 05:26 PM.
 
Old 11-19-2008, 01:59 PM   #3
plasya777
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for your reply.
 
Old 11-19-2008, 02:07 PM   #4
plasya777
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Original Poster
Rep: Reputation: 0
We were able to call the other scripts from within the cygwin tool just by manually running each script.(./scriptname.sh)
However we need this to be done automatically(at scheduled times)
For Ex : if we need to run a script called script1.sh on every Monday morning at 4.30AM we need to schedule this script in such a way that every Monday morning 4.30AM cygwin tool should be started and the script should be executed from within the cygwin tool automatically.Can we do this ?
Thanks in advance.
 
Old 11-20-2008, 07:42 PM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
On this thread:

http://forums.techguy.org/windows-nt...os-script.html

I answered your question a few years ago.

The essential detail is that you can execute a cygwin script within a DOS batch file like this:

start c:\cygwin\bin\bash.exe -l myscript
 
Old 05-04-2009, 08:53 AM   #6
bart.wallebroek
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
I tried to perform this

C:\cygwin\bin>c:\cygwin\bin\bash.exe -l <script>

But I get this response:

Your group name is currently "mkgroup_l_d". This indicat
all domain users and groups are listed in the /etc/passw
/etc/group files.
See the man pages for mkpasswd and mkgroup then, for exa
mkpasswd -l -d > /etc/passwd
mkgroup -l -d > /etc/group

This message is only displayed once (unless you recreate
and can be safely ignored.
cp: `Settings/<user_account>/group.mkgroup_l_d': specified
Try `cp --help' for more information.
cat: XXXXXXlog: No such file or directory

in the scritps (1st line) it needs to perfrom a cat of a log file (which resides in the same folder (C:\cygwin\bin)

When i just run the bash file and try to run a cat from there it shows me this:

command:
c:\cygwin\bin\bash.exe
result:
C:\cygwin\bin>c:\cygwin\bin\bash.exe
bash-2.05b$ <script>
bash: available_tapes: command not found

Someone any idea ? I just want to run a Windows scheduled task that launches a unix script with Cygwin.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell scripts in Windows Cygwin Micro420 Programming 14 10-17-2009 12:25 PM
How to run a BASH script in a Batch file (with Cygwin) FaeDine Programming 2 10-27-2007 05:47 PM
Running Windows batch script from Unix rrguyyala AIX 4 08-26-2007 09:43 AM
how to write a batch file to make a program run during boot up in windows??? b0nd Programming 7 09-04-2006 07:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration