LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-02-2009, 09:31 AM   #1
celticdaddio
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Rep: Reputation: 0
Cross platform BASH scripts?


I currently have apps that are compiled for execution on Windows and Linux and distributed.

I have a bash script that collects and tars the files needed for a linux distribution. I have similar batch files on winows.

Rather than maintain and enhance, as needed, a bash script and a batch file for every product, I would like to have a single script for each app, maybe even a single script for all apps, on both linux and windows.

I had originally thought about using python, or perl, to do this, but I already have pretty decent bash files and batch files done.

I know I can run bash scripts under Cygwin on a windows machine, but will that allow me to access all the files on the Windows machine, outside of the cygwin home?

Any suggestions on how YOU would handle this?

CD
 
Old 10-02-2009, 10:32 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,615

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by celticdaddio View Post
I currently have apps that are compiled for execution on Windows and Linux and distributed.

I have a bash script that collects and tars the files needed for a linux distribution. I have similar batch files on winows.

Rather than maintain and enhance, as needed, a bash script and a batch file for every product, I would like to have a single script for each app, maybe even a single script for all apps, on both linux and windows.

I had originally thought about using python, or perl, to do this, but I already have pretty decent bash files and batch files done.

I know I can run bash scripts under Cygwin on a windows machine, but will that allow me to access all the files on the Windows machine, outside of the cygwin home?

Any suggestions on how YOU would handle this?

CD
Well, I'd probably drop support for Windows, which would greatly simplify things.

As far as I can remember, Cygwin will only be able to see what's in the Cygwin home, but I could be mistaken. Don't have alot of experience with it, but I do seem to remember that. Perl is a great solution, but you may have problems with Windows, though, since not all Windows boxes have a decent (or any) Perl installation.

If you had a Samba mount from your Linux box to your Windows box (smbclient), you could use your Linux script to create a Windows 'set', or use Windows to mount the Linux box, and do it the other way around.

Without knowing more about your environment, and what you're trying to do, it's hard to say more.
 
Old 10-02-2009, 10:37 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Install MKS on the Windows systems? Mortice Kern Systems? *n*x utilities running under native Windows?
 
Old 10-02-2009, 10:41 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by celticdaddio View Post
I know I can run bash scripts under Cygwin on a windows machine, but will that allow me to access all the files on the Windows machine, outside of the cygwin home?
Yes. All drives available in Windows (C:\, D:\, E:\ etc.) are "mounted" under /cygdrive with their respective drive letter as the folder. Cygwin has a clever parser for Windows paths, thus, to access C:\Program Files using Cygwin, you can either do:
Code:
cd "C:\Program Files"
Or, you can do:
Code:
cd /cygdrive/c/Program\ Files
 
Old 10-02-2009, 02:15 PM   #5
celticdaddio
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks for all the answers. Is sounds like Cygwin may be my best choice. How about MinGW/MSYS? I had forgotten about MinGW/MSys until after I posted my question(s).

CD
 
Old 10-02-2009, 02:17 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
MinGW / MSYS works fine also
 
Old 10-03-2009, 03:25 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
There are also strand-alone nix-like utilities for use under win32, but no full bash shell. I have seen a version of zsh for windows. Would save having to have msys or cigwin installed, but you'd probably have to change some of your script syntax to use zsh instead of bash.
 
Old 10-03-2009, 05:22 AM   #8
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 533

Rep: Reputation: 129Reputation: 129
I had used zsh from the unixutils in sourceforge in all
versions of windows up to XP with no problems.
However in vista it didn't work so well (crashes occasionaly).

msys on the other hand (with bash as its default shell) worked
perfectly in vista

As far as I'm concerned msys is much better than cygwin.

If you use standard sh syntax you can use exactly the same script
with bash or zsh (zsh has features found in korn and bash shell
but it uses a different syntax on some of these: arrays, setting
the prompts PS1, etc.)
 
Old 10-03-2009, 05:46 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by catkin View Post
Install MKS on the Windows systems? Mortice Kern Systems? *n*x utilities running under native Windows?
Sorry for part-information; I was in a hurry and wanted to at least leave some pointers that might be useful. MKS may help; it is commercial and has shifted its focus from "UNIX utilites on Windows" to "Developlment life cycle toolkits". Nonetheless, from the MKS site, "MKS Toolkit for Developers ships with many commands and utilities — awk, sed, Perl, CShell, KornShell, Graphical KornShell, and more". According to this press release, bash is included in version 8.6.
 
  


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
Cross-Platform Programming JMJ_coder Programming 7 03-11-2007 12:59 PM
cross platform macros dmail Programming 4 12-20-2005 09:16 PM
cross platform c++ nyomon Programming 6 07-03-2005 03:24 PM
Cross-Platform LibAO Ross Clement Programming 0 03-05-2005 05:19 AM
Cross Platform biggiefatts Linux - Software 4 06-04-2002 03:00 PM

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

All times are GMT -5. The time now is 08:38 AM.

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
Open Source Consulting | Domain Registration