cygwin bash startup command weirdness (part 1)

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cygwin bash startup command weirdness (part 1)
# 1  
Old 12-02-2007
cygwin bash startup command weirdness (part 1)

I am running (I believe) the latest stable version of cygwin
CYGWIN_NT-5.1 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
on a win xp sp2 laptop.

Suppose, to make things simple for now (but I may do a part 2 posting...), that I am in a dos shell, and I want to create a bash shell and have it execute a few commands before closing and returning to the dos prompt.

I have experimentally found that this (dos) command line does the trick:
c:\cygwin\bin\bash.exe --login -c "pwd && ls -a"
It outputs
. .. .bash_history .bash_profile .bashrc .inputrc
as expected, and then closes and returns to dos. Note that the working directory is my home directory, /home/BKernigan, and that its contents (all bash related config files) are correctly listed.

This (dos) command line
c:\cygwin\bin\bash.exe -i -c "pwd && ls -a -l"
(same as above except that -i replaces --login) partially works; it outputs
bash: ls: command not found
Here, it thinks that the working directory is the directory where I created the dos shell (d:\unix\nextVersion\script), as opposed to my cygwin home, so that is one difference from the --login version. And then, for some bizarre reason, the ls command is not found! Hmm, how can it find the pwd command but not ls? Note that the ls command really is in my cygwin installation (this is known both because the ls command in the first example worked, and I can also assure you that ls.exe is found in C:\cygwin\bin).

Does anyone have any idea what is going on here???

The web research that I did does not seem to answer this question. (The best single reference being the generic bash reference Bash Reference Manual: Invoking Bash, but I found it to be quite complex.)

Forgive me in advance if this is such an obvious error on my part.

Also, if this is not the best forum--or even the best website--for this question, by all means suggest to me where I should go and I will repost it there.
# 2  
Old 05-19-2008
Ensure Path Settings

Ensure that you have set your PATH variable(in MyComputer) to point to %CYGWIN_HOME%/bin

When you are planning to run the shell script, ensure, you have sh.exe present in your %CYGWIN_HOME%/bin. you can get this file from


Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Script (tar + md) on Cygwin

Hi everybody, First, I'm sorry for my bad english! I have the following situation: I have a Windows 2012 R2 with Cygwin installed. The Windows Server is used as a backup Server with Dell AppAssure installed. At the moment, AppAssure saves Backup Targets to a repository on his D. The... (9 Replies)
Discussion started by: fibra3000
9 Replies

2. UNIX for Dummies Questions & Answers

Bash on CygWin

I am using CygWin to run a bash file but I am getting weird results. #!/bin/bash mkdir CLEANDATA mv *FASTA CLEANDATA cd CLEANDATA ls echo "COMPLETE" And this is what I get $ ./Pipe.txt ./Pipe.txt: line 5: $'ls\r': command not found COMPLETE Moreover, the new folder is... (1 Reply)
Discussion started by: Xterra
1 Replies

3. UNIX for Dummies Questions & Answers

How to downgrade cygwin to a part. version?

I'd like to compile gxemul under cygwin, Here a nice guy who ported the source code, but the prerequisites are needing the exact versions of the libraries If I download the setup.exe from canonical cygwin web site, it automatically installs me the... (1 Reply)
Discussion started by: lucky7456969
1 Replies

4. Shell Programming and Scripting

Help with bash scripting in cygwin

Hi, I am trying to write a bash script, to open firefox and then open a local webpage in a tab. This is a shell of what I have #! /bin/sh alias firefox='/cygdrive/c/Program\ Files/Mozilla\ Firefox/firefox.exe' $URL='/cygdrive/d/Playback.html' firefox & sleep 1 for i in 1 2 3 4 5 #6 7 8 9... (1 Reply)
Discussion started by: jamie_123
1 Replies

5. Shell Programming and Scripting

Need help with simple startup bash script in CentOS

Hi guys, I am very new to linux, so please bear with me. I need a simple script (bash / .sh) to start 2 programs at server startup. Both programs should run in a detached screen of their own. So basically: 1) start a detached screen with... (2 Replies)
Discussion started by: lastcrafters
2 Replies

6. Shell Programming and Scripting

redirect time command output to file (cygwin bash)

I have set up a bash script to run a long list of things that I need to time. I would like to redirect the output of time to a file. I have set it up like, echo "Runtimes for servlet 4, 100K structures" > test_times.txt echo "" >> test_times.txt echo "runs where N=10" >> test_times.txt echo... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

7. Shell Programming and Scripting

bash command in makefile (cygwin)

Hello, In my make file (make 3.81), I use a combination of shell commands to automatically create the name of my build directory. OS := $(shell uname -s) ARCH := $(shell uname -m) KERN := $(shell uname -r | cut -d. -f 1,2) BDIR := $(OS)_$(KERN).$(ARCH)When I boot into different OSs, I... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

8. UNIX for Dummies Questions & Answers

Cygwin bash script and read command

Hello everyone, I am struggling a bit with a batch script that I need to run in cygwin. I work in winXP and I had to write some awk scripts to do some file manipulation, and now I would like to automate the process by just running a batch file so that my colleagues can use it easily. Now, the... (2 Replies)
Discussion started by: Teroc
2 Replies

9. Shell Programming and Scripting

unzip via bash startup script problems

i have two lines in my rc.local file that are wget -O/<path>/<file>.zip url:// unzip -o /<path>/<file>.zip the wget works fine, but the unzip won't work. when i copy/pase the unzip line to the prompt it works fine. i thought that maybe the unzip was running before the wget... (0 Replies)
Discussion started by: easysnowboards
0 Replies

10. UNIX for Dummies Questions & Answers

How to use cygwin to run bash script

Hi, all, I try to run a quite simple bash script in cygwin, it's content is: #!/bin/bash echo "It is my first bash shell" there are three lines in the script. The second line is blank line. When I run it use command: bash c:/, ... (6 Replies)
Discussion started by: Jenny.palmy
6 Replies
Login or Register to Ask a Question