Sponsored Content
Full Discussion: Using BASH on windows
Top Forums Shell Programming and Scripting Using BASH on windows Post 302836263 by durden_tyler on Tuesday 23rd of July 2013 10:45:44 PM
Old 07-23-2013
Quote:
Originally Posted by Cambria
...I tried ls, and cat but neither did anything. ...
Since you appear to be new here, I'd like to mention that the way to get the quickest responses is to actually cut and paste your commands and their responses from your terminal.

"xyz is not working" or "xyz does not do anything" are very vague statements; somewhat like calling your car mechanic and telling him "my car won't start". There could be a lot of reasons for that and the mechanic won't know what's wrong with your car unless he actually inspects it himself. It's the same thing over here.

In any case, here are the steps to install Cygwin from what I could remember; see if you followed them all.

(1) You have a working (non-corrupted) version of Windows and you downloaded setup.exe from the Cygwin website.
(2) If your computer is 32-bit, you downloaded the 32-bit version of setup.exe, or ditto for 64-bit.
(3) You double-clicked on setup.exe and clicked through the wizard to install Cygwin. In the final screen, it shows you an option to put up an icon on your Windows desktop. If you had checked that, you'd see the Cygwin icon on your desktop.
(4) Assuming that you do see the icon; if you double-click on it, the Cygwin shell would've opened up. By default, it is the Bash shell, and you'd see a "prompt". If you keep on pressing the "Enter" or "Return" key, you'd see the prompt printed repeatedly, because it is waiting for you to enter a command.
(5) Now, "ls" and "cat" are pretty basic commands, so they should be installed as a part of the core setup. If you've done everything till now as mentioned above, then run the following commands at your prompt:

Code:
type ls

and then

Code:
type cat

They should provide you some information about what "ls" and "cat" are in your system. Run those commands and paste their output over here.

(6) The "ls" command without any argument lists all the files (which includes directories in Unix/Linux) in the current directory. So if you are in an empty directory, "ls" won't print anything and you'll simply see your prompt printed in the next line. Maybe that's what you are confused about?
Try the following command:

Code:
ls -al

This will print a long listing of all files, including hidden files, which in Unix/Linux are the ones that start with "." character. You should see atleast two lines printed. Post the output of this command over here.

(7) The "cat" command "concatenates" the contents of the files you pass as arguments.
- If you pass one argument, it will print the contents of that file.
- If you pass two arguments, it will print the contents of the two files one after the other. Ditto with more than two arguments.
- If you don't pass any arguments and press "Enter", it will simply wait for you to enter something. Once you enter something, it will simply echo your input.
Maybe that's what you saw?

Try this command:

Code:
cat myfile

If a file called "myfile" exists in your current directory, this command will print its contents. If it does not, it will show an appropriate error message. Cut and paste the output of that command over here.

Quote:
Originally Posted by Cambria
...
I tried running a program that I created which accepts command line arguments and prints them on screen. When I give it my argumeets in bash they always come up NULL, ...
Without knowing:
(a) what that program is
(b) what language it is written in
(c) how it was saved or compiled in your system
(d) how it was invoked by you
(e) how you passed the arguments to it

it is difficult to say why it came up with NULLs.

Let's say you saved your program in a file called "myfile". Then run the following command:

Code:
cat myfile

and paste its output over here.
And then copy and paste the command(s) you ran to invoke it and the response you received.
This User Gave Thanks to durden_tyler For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (1 Reply)
Discussion started by: rajuchacha007
1 Replies

2. Shell Programming and Scripting

Writing Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (15 Replies)
Discussion started by: rajuchacha007
15 Replies

3. Shell Programming and Scripting

Windows to Unix? Using bash

Im posting here as i posted this in the wrong section before, sorry about that. Ok, im doing a self teaching course, im trying to understand how unix works, get and understand the basics before i hit the advance level. Now i have this in windows, Btw im always new at windows so correct me if... (9 Replies)
Discussion started by: newbie987
9 Replies

4. Shell Programming and Scripting

How to run Cygwin bash from windows scheduled task?

Hmmm.... I love these forums because I always get great prompt responses and I want to ask a question about running bash on windows. Is that allowed? Now I know I can install cygwin cron and run bash that way. Can I run bash from windows schedule task? How? thanks siegfried (1 Reply)
Discussion started by: siegfried
1 Replies

5. Shell Programming and Scripting

File descriptors -- cygwyn bash (windows)

Cygwin bash script was invoked in bash shell as follows: /cygdrive/c/cygwin/bin/bash test.sh This is content of my script #!/bin/bash # exec 3</cygdrive/c/cygwin/home/work/part1.txt read -u 3 x echo $x exec 3<&- Commands work correctly when issued one at a time within bash shell.... (2 Replies)
Discussion started by: joed270
2 Replies

6. Shell Programming and Scripting

How to start powershell with shebang from windows/cygwin/bash?

I would like to the the windws8/cygwin/bash shebang feature to start a powershell script. I do a "chmod +x set-sound.ps1" and then at a bash prompt I do ./set-sound.ps1 The first line of ./set-sound.ps1 #!powershell.exe -ExecutionPolicy unrestricted The result is the result: ... (5 Replies)
Discussion started by: siegfried
5 Replies

7. Windows & DOS: Issues & Discussions

Run Bash from Windows icon?

Is it possible to run a bash using a by creating an icon or shortcut in windows 7? Everything seems to be for unix or linux and unfortunately my institution is windows. For example, run bash ~/newbatch.sh by clicking on an icon on a users desktop. Cygwin will be installed as well. Thank you... (8 Replies)
Discussion started by: cmccabe
8 Replies

8. Shell Programming and Scripting

Windows Task with Bash script

Hello I have a problem with use bash script in windows task. If I use script by cygwin it's working well. If I use it by Windows task I'm get error Error : ERROR 2 (HY000) at line 2: File '.\xxx.csv' not found (Errcode: 2) Code Line : load data local infile './xxx.csv' REPLACE into... (16 Replies)
Discussion started by: karp
16 Replies

9. UNIX for Beginners Questions & Answers

Windows Batch to Bash

This line is called in a windows batch file and I need to call the same 3 jars with Parms in a bash script. cd "D:\ACDRIP\JARS" java -cp ".\RIPError.jar;.\RIP31.jar;.\RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 pause Any ideas how to do this in Bash? (3 Replies)
Discussion started by: xgringo
3 Replies
All times are GMT -4. The time now is 08:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy