Changing directory in bash for GNU - windows

I have never worked with Linux and hence I am ignorant in the commands.However, I need to use the GNU for win64 environment for one of the programming tools to function. I have downloaded the GNU from cygwin. This package includes gcc and various commands and
shells (sh, bash, etc.) that make the PC have a unix
like environment.
I have to change to the directory of the program code MyPrograms and type "make all".
On opening the terminal of cygwin i get this line >> -bash-4.1$
Question is what is the command for changing to the directory MyPrograms;what do I type in after -bash-4.1$

If your MyPrograms folder is located at C:\MyPrograms, then in Cygwin, type:
cd /cygdrive/c/MyPrograms
Refer to this FAQ

Related

`gitk` program found using the `where` command but cannot be executed?

I'm trying to run gitk on Windows but the console gives me:
'gitk' is not recognized as an internal or external command,
operable program or batch file.
But then, I can do
> where gitk
C:\Program Files (x86)\Git\bin\gitk
How comes?
UPDATE: Stealing the OP's comment:
Thanks for a (lengthy) explanation, the easiest fix for me was to move from the old msysGit (1.9.5) version to the newer "Git for Windows" builds which has a proper Windows wrapper for gitk.
gitk, unlike most git commands, is a shell script that invokes Tcl.
If you examine the gitk executable file itself, its first few lines are:
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$#"
(At least that's what it looks like on my Linux system; the Windows installer for gitk might change that.)
On a Unix-like system, that first line, known as a "shebang", tells the system to invoke /bin/sh to execute the file rather than executing it directly.
The third line executes the wish command, which executes the script as a Tcl script.
If you have Tcl installed on your Windows system, you should be able to run gitk as a Tcl script using something like this:
C:\> tclsh "C:\Program Files (x86)\Git\bin\gitk"
(Disclaimer: I have not tried this.)
You might also be able to change the command's name from gitk to gitk.tcl and set up a file association in Windows so it will be invoked correctly. (I'm a little surprised that the Windows git installer didn't do this for you.)
More information on running Tcl scripts on Windows can be found here.
And this question discusses invoking gitk on Windows from the context menu rather than from the command line.

Command prompt isn't integrating anything

I installed amazonCLI, as well as Cygwin, and changed the Path env variable to:
%SystemRoot%\System32\Wbem;C:\Program Files\Prio;C:\Program
Files\Diskeeper Corporation\ExpressCache\;C:\Program
Files\Amazon\AWSCLI\;C:\cygwin64\bin
When I open the command prompt, first of all it is directly pointing to
C:\Users\Stephane
(which I think is weird). And then when I input something like 'ls', the return error is:
'ls' is not recognized as internal or external command, operable program or batch file
Can you please help me know what I am doing wrong?
Thanks
From the error message you got, it's evident, that you are trying to execute Cygwin's commands from the Windows Console. That's also the reason, why it's executed in your Windows' profile directory instead of the Cygwin's one.
You should read the basics about using the Cygwin first, because it seems you don't know what Cygwin exactly is and how to use it. Maybe you don't need the Cygwin at all, it depends on what you need to accomplish. The is for example GnuWin tool set or UnxUtils, which are just a sets of standalone GNU tools compiled for Windows. Cygwin is more like system than standalone utilities. You can for example execute shell scripts under the Cygwin.
So it depends on your needs. But I simply can't imagine using Windows without Cygwin yet.
You can execute Cygwin's shell from the Windows Console, but I advice you to use MinTTY (which is in directory $CYGWIN_DIR/bin). MinTTY is a terminal emulator, which executes your Cygwin shell (bash by default).
To execute for example bash directly from the Windows Console, just execute $CYGWIN_DIR/bash.exe --login -i.

Unable to execute shell script in Cygwin as a KornShell script

I rarely touch shell scripts, we have another department who write them, so I have an understanding of writing them but no experience. However they all appear rather useless with my issue.
I am trying to execute some KornShell (ksh) scripts on a windows based machine using Cygwin- we use these to launch our Oracle WebLogic servers, now it simply will not execute. I used to be able to execute these exact same scripts fine on my old machine.
Now I have narrowed this down to the fact the 'magic number' or whatever it is at the start of the script where it specifies the script interpreter path:
i.e.:
#!/bin/ksh
if I change it to execute as a simple bash it works i.e:
#!/bin/sh
I went through checking the packages installed for cygwin - now the shells I installed are:
mksh MirdBSD KornShell
bash the bourne again shell
zsh z shell
Should I expect to see a ksh.exe in my cygwin/bin directory? there is a system file 'ksh' which I was making an assume somehow associates it with one of the other shell exes, like mksh.exe
I understand my explanation may well be naff. But that being said, any help would be very much appreciated.
Thanks.
I believe the MirBSD korn shell is called mksh. You can verify this and look for the correct path by typing
% which mksh
% which ksh
or if you have no which,
% type -p mksh
% type -p ksh
or if that fails too, check /etc/shells which should list all valid shells on a system:
% grep ksh /etc/shells
You need to put the full path after the #! line. It will probably be /bin/mksh, so your line needs to look like:
#!/bin/mksh
You've probably fixed it by now, but the answer was no, your Cygwin does not (yet) know about ksh.
I solved this problem by launching the cygwin setup in command-line mode with the -P ksh attribute (as described in http://www.ehow.com/how_8611406_install-ksh-cygwin.html).
You can run a ksh using a bat file
C:\cygwin\bin\dos2unix kshfilename.ksh
C:\cygwin\bin\bash kshfilename.ksh
Running a shell script through Cygwin on Windows
Install KornShell (ksh) into Cygwin by the following process:
Download: ksh.2012-08-06.cygwin.i386.gz
Install ksh via Cygwin setup.
Execture Cygwin setup.exe
Choose: Install from Local Directory
Select the ksh.2012-08-06.cygwin.i386.gz as the Local Package Directory.
Complete Cygwin setup.
Restart Cygwin.

How can I get Cygwin to accurately read my Windows environment variables?

I'm using Windows XP with the latest version of Cygwin. If I set the following environment variable in my Windows system
JBOSS_HOME=C:/Program Files/jboss-4.2.3.GA
and then fire up Cygwin, I'm unable to switch to the inherited $JBOSS_HOME directory.
$ cd $JBOSS_HOME
cygwin warning:
MS-DOS style path detected: C:/Program
Preferred POSIX equivalent is: /cygdrive/c/Program
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
-bash: cd: C:/Program: No such file or directory
Is it possible to define my system variable once in the Windows environment and then get Cygwin to interpret it so that I don't get this "No such file or directory" warning?
You could do one of two things...
Add a command to convert the path in your .bashrc file, like so...
export JBOSS_HOME=$( cygpath "$JBOSS_HOME" )
or
Just put the variable between quotes when referencing it, since Cygwin understands DOS style paths, even though it doesn't prefer them. The reason the command is failing for you is that there is a space in the path, so putting it in quotes will get the path to be read correctly as one arg...
cd "$JBOSS_HOME"
Note that you might still get that same "cygwin warning" in this case. In order to make that go away, you need to add nodosfilewarning to your CYGWIN var as the warning advises. You can do that by adding this in your .bashrc file...
export CYGWIN="${CYGWIN} nodosfilewarning"
I am using Eclispse with ShellED plugins,
I got the same notification, not knowing the accurate configuration,
I just add the export value into the script
'#!/bin/bash'
export CYGWIN="${CYGWIN} nodosfilewarning"
echo hello
This works for me
$ SEVENZIP="C:/Program Files/7-Zip"
$ read < <(cd "$SEVENZIP"; pwd)
$ cd "$REPLY"

Why does MinGW/MSys change the binary path?

I'm using Mingw to build a C/C++ project. This project has makefiles beyond my comprehension, and relies on a custom and quite sophisticated toolchain to compile it. It's quite convenient to have GNU tools available on Windows, especially from Windows's cmd shell, but while invoking the tools (make in particular), MinGW seems to change my PATH around.
Cmd does it normally:
echo %PATH% > ... c:\Apps\msys\bin ... (from cmd)
but msys changes this address to :
echo $PATH > ... /usr/bin ...
in msys, even when I print the PATH from a makefile. As a result, make complains that it can't find commands like make, uname, echo, you name it (no pun intended).
Strangely, I managed to get this environment working ages ago without a hitch, but this is the first time I remember seeing this path problem. How can I get MinGW/msys to correctly point to its executables?
richard has a point - there were two different shells fighting over environment variables (not to mention running msys) and so each parsed its own and the system's environment variables differently.
Also make sure that variables defined in your user or system environment are properly written - Windows likes "C:\foo\bar" style paths, but Msys treats them as "/c/foo/bar".

Resources