command line shell
echo %PIG_HOME%
C:\cygwin\usr\lib\pig
cygwin
echo $PIG_HOME
C:\cygwin\usr\lib\pig
echo $( cygpath -u "$PIG_HOME" )
/usr/lib/pig
cd $( cygpath -u "$PIG_HOME" )
-bash: cd: /usr/lib/pig: No such file or directory
Question: why is cygpath not converting it to /cygdrive/c/cygwin/usr/lib/pig?
UPDATE:
The path to the pig folder is correct.
command line shell
C:\Users\john.doe> cd %PIG_HOME%
C:\cygwin\usr\lib\pig>
cygwin
john.doe#COMPUTER ~
$ cd /cygdrive/c/cygwin/usr/lib/pig/
john.doe#COMPUTER /cygdrive/c/cygwin/usr/lib/pig
$
With Cygwin,
C:\cygwin\lib\pig = /usr/lib/pig
and
C:\cygwin\usr\lib\pig = /cygdrive/c/cygwin/usr/lib/pig
This setup is by design.
The C:\cygwin\usr\lib folder is not created by any packages and should not be created by you either.
Type mount in your terminal window.
My c:\cygwin\bin and c:\cygwin\lib\ are mounted at /usr/bin and /usr/lib respectively. I suspect that your c:\cygwin\usr\lib is mounted at /usr/lib.
Therefore, the "unix" path to c:\cygwin\usr\lib\pig would be /usr/lib/pig.
Did you try option "-m, --mixed : like --windows, but with regular slashes (C:/WINNT)"
$ cd /cygdrive/c/cygwin64/home
$ cygpath -m $(pwd)
C:/cygwin64/home
Related
I created a simple shell called glang then made it executable.
$ chmod +x glang
Then I copied it into /bin
$ sudo cp glang /bin
I made it work. However, then I wanted to delete it and went to /bin
$ cd /bin
Then delete it.
$ sudo rm glang
And when I listed files, I couldn't find the script, then I thought it's been deleted.
However, when I still write
$ glang
any where in the file system, the script still works!
Any idea whats going on?
Thanks in advance.
Content of glang is as follows(It's basically a preprocessor thing):
#!/bin/bash
echo $1 >> ~/lexer/var.cl
echo "\")" >> ~/lexer/var.cl
cat ~/lexer/var.cl >> ~/lexer/exe.cl
cat ~/lexer/char_processing.cl >> ~/lexer/exe.cl
cat ~/lexer/io_processing.cl >> ~/lexer/exe.cl
cat ~/lexer/lex_processing.cl >> ~/lexer/exe.cl
cat ~/lexer/main.cl >> ~/lexer/exe.cl
clisp ~/lexer/exe.cl
Try:
whereis <script name>
Under linux you should use /usr/local/bin for custom scripts that you create. That location is in the PATH and you can use your script from that location. So it's not a good idea to replace the "buildin" scripts. You can call the buildin script with:
buildin glang
If the scripts are installed over the package manager you can search with which or whereis. When you use the same name like the original one you can get problems. So you should give them another name.
My cygwin used to work properly before, but suddenly it starts to complain: "file does not exist" under /cygdrive/d ...
The problem looks like this: if I cd to that folder I can saw that file and cat/ls afile without any problem, but if I use something like ls /cygdrive/d/afile it will complain "file does not exist".
So I traced backwards on the file system, and found there's some issue with the virtual path /cygdrive
/cygdrive
cd /cygdrive/
Error: Current working directory is a virtual Cygwin directory which
does not exist for a native Windows application. Can't start native
Windows application from here.
Seems this /cygdrive is broken, does anyone know how to fix it?
Adding more detail:
$grep cygdrive /etc/fstab
# none /cygdrive cygdrive binary,posix=0,user 0 0
$type -a cd
#cd is a shell builtin
I get that error message if I do a cd /cygdrive and then try to execute a (non-Cygwin) Windows command. I don't get it if I just cd /cygdrive.
The only explanation I can think of is that you've assigned a value to the bash special variable $PROMPT_COMMAND.
Quoting the bash documentation:
'PROMPT_COMMAND'
If set, the value is interpreted as a command to execute before
the printing of each primary prompt ('$PS1').
For example:
$ PROMPT_COMMAND=cmd.exe ; cd /cygdrive
Error: Current working directory is a virtual Cygwin directory which does
not exist for a native Windows application.
Can't start native Windows application from here.
-bash: /cygdrive/c/Windows/system32/cmd.exe: Not a directory
move to the right directory by replacing (if you are in C drive for example)
cd /cygdrive
by
cd c:/cygdrive
also suitable:
cd /c/<rest of your path>
I'm learning some shell commands on ubuntu 12.04. But I had a hard time unaliasing something I have set before. For example,
$ alias dir ls
$ dir
[some files and directories]
$ unalias dir
- no such command.
Does Ubuntu not support dir command? How can I de-aliasing dir using shell command?
First you ahve to define your alias using this syntax:
alias dir=ls
Then you can check if it worked out:
me#foo:~alias
alias dir='ls'
alias l.='ls -d .* --color=auto'
...
After this works you can simply unalias with:
unalias dir
I think the dir command is a binary in Ubuntu, you can check this using:
which dir
If it gives you a path to an executable you know that dir is no alias.
I am having trouble executing a program located in the "C:\Program Files (x86) directory in Windows from within Cygwin. Anyone know the trick to getting this to work?
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help"
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash $wgetexe
bash: /cygdrive/C/Program: No such file or directory
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash "$wgetexe"
bash: /cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help: No such file or directory
Try this:
wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe"
"$wgetexe" --help
Since it's an executable, you don't want to pass it as an argument to bash, which will try to execute it as a script. Since it has spaces in the path name, you need to quote the name so the shell doesn't try to execute cygdrive/C/Program with invalid arguments.
You should also be able to add the directory to your $PATH:
PATH="$PATH:/cygdrive/C/Program Files (x86)/GnuWin32"
Keep in mind that GnuWin32 programs are Windows executables, and any file paths they use will be interpreted using Windows syntax. Cywin executables (anything that uses cygwin1.dll) use Cygwin path syntax.
Better yet, install the Cygwin version of wget and just invoke it as wget --help.
For example, if you're using the GnuWin32 wget, you might use:
wget -O "C:\cygwin\home\yourname\output-file" "$url"
whereas with the Cygwin wget you might use:
wget -O "/home/yourname/output-file" "$url"
I've always found it easiest to use Cygwin executables from Cygwin whenever possible.
Try this, it always worked or me.
wgetexe="/cygdrive/C/Program\ Files\ \(x86)/GnuWin32/wget.exe"
"$wgetexe" --help
I write a simple shell script to clean log files in redhat:
Filename: clean.sh
#!/bin/bash
rm -f *.log core.*
But when I typed clean or clean.sh, it always prompt
-bash: clean: command not found
-bash: clean.sh: command not found
What's the problem?
You probably don't have . (the current directory) in your $PATH (and that's a good thing; having . in your $PATH can be dangerous.)
Try this:
./clean.sh
And if the script file's name is clean.sh you can't run it as just clean, with or without a directory. The file name is clean.sh, and that's how you need to execute it.
Or you can change the name from clean.sh to just clean. Unix-like systems (that includes Linux) don't depend on file extensions the way Windows does.
problem 1: maybe the execute permission on clean.sh is not set. Do this:
chmod +x ./clean.sh
problem 2: RH Linux does not include CWD on the path by default. So, when you are in the same directory as clean.sh, type:
./clean.sh
That should execute it.