Cygwin commands don't work - command

I'm sorry that my question seems rather vague but this is the entire problem i'm facing. I tried installing an rpm package on cygwin after downloading it from the website but i always get the same error
-bash: rpm: command not found
and I have reinstalled it twice, but i always get the same problem, and it's not just that, i can't even use simple commands like ls. Even if i write ls I get no output. This is what my screen looks like.
User#User-PC ~
$ rpm -ivh avr-binutils-2.17tinyos-3.cygwin.i386.rpm
-bash: rpm: command not found
User#User-PC ~
$ locate rpm | grep bin
User#User-PC ~
$
User#User-PC ~
$ ls
User#User-PC ~
$
what do I do to fix this?

First, locate does not auto-update itself; you must run updatedb periodically to get the current list of files. For optimal speed and usability, add the --prunepaths and --prunefs switches.
Second, try echo $PATH to see the current path, and call ls with a fully-qualified pathname: /bin/ls -l
I suspect ls is set to an invalid alias or internal function (bad command parameters). Check the contents of ~/.bash_profile, ~/.bashrc, and ~/.profile .

Related

Perl Returning error for ls -l command

I am running a perl script from Nagios to check some files for certain characteristics on a windows machine. When I run the script from Nagios it responds with a result of:
UNKNOWN ERROR - execution of LANG=C ls -l resulted in an error 32512 -
My Code is from this GitHub with a single modification of line 168 so I can use it with windows:
use lib 'C$\Progra~1\Nagios\NRDS_Win\plugins';
The odd thing is the program actually outputs the expected result from the command line on the windows machine.
Here is the command:
check_files.pl -D c:\logs -F Health.log -a '~,300'
Here is an example:
CRITICAL - Health.log is 10703 (more than 300) seconds old - 1
Health.log files found
I modified line that defined LANG=C ls -l in the code but now i just get:
UNKNOWN ERROR - could not execute ls -l - No such file or directory
ls is unix command and by default there is no such command in windows.
If you need it, you can install it e.g. from GNU CoreUtils
You also need to change shell command on line 639 from LANG=C ls -l to just ls -l because in windows you can't set environment variables like that.

How to send data to command line after calling .sh file?

I want to install Anaconda through EasyBuild. EasyBuild is a software to manage software installation on clusters. Anaconda can be installed with sh Anaconda.sh.
However, after running I have to accept the License agreement and give the installation location on the command line by entering <Enter>, yes <Enter>, path/where/to/install/ <Enter>.
Because this has to be installed automatically I want to do the accepting of terms and giving the install location in one line. I tried to do it like this:
sh Anaconda.sh < <(echo) >/dev/null < <(echo yes) >/dev/null \
< <(echo /apps/software/Anaconda/1.8.0-Linux-x86_64/) > test.txt
From the test.txt I can read that the first echo works as <Enter>, but I can't figure out how to accept the License agreement, as it sees it now as not sending yes:
Do you approve the license terms? [yes|no]
[no] >>> The license agreement wasn't approved, aborting installation.
How can I send the yes correctly to the script input?
Edit: Sorry, I missed the part about having to enter more then one thing. You can take a look at writing expect scripts. thegeekstuff.com/2010/10/expect-examples. You may need to install it however.
You could try piping with the following command: yes yes | sh Anaconda.sh. Read the man pages for more information man yes.
Expect is a great way to go and probably the most error proof way. If you know all the questions I think you could do this by just writing a file with the answers in the correct order, one per line and piping it in.
That install script is huge so as long as you can verify you know all the questions you could give this a try.
In my simple tests it works.
I have a test script that looks like this:
#!/bin/sh
echo -n "Do you accept "
read ANS
echo $ANS
echo -n "Install path: "
read ANS
echo $ANS
and an answers file that looks like this:
Y
/usr
Running it like so works... perhaps it will work for your monster install file as well.
cat answers | ./test.sh
Do you accept Y
Install path: /usr
If that doesn't work then the script is likely flushing and you will have to use expect or pexpect.
Good luck!
Actually, I downloaded and looked at the anaconda install script. Looks like it takes command line arguments.
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -h
usage: Anaconda-2.2.0-Linux-x86_64.sh [options]
Installs Anaconda 2.2.0
-b run install in batch mode (without manual intervention),
it is expected the license terms are agreed upon
-f no error if install prefix already exists
-h print this help message and exit
-p PREFIX install prefix, defaults to /home/cody.stevens/anaconda
Use the -b and -p options...
so use it like so:
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -b -p /usr
Also of note.. that script explicitly says not to run with '.' or 'sh' but 'bash' so they must have some dependency on a feature of bash.
--
Cody

Which yum group(s) contain a given package?

Is there a way to ask yum which group(s) contain a given package? I know how to ask what packages are in a given group, and could write a quick script to trawl over all of the groups, but it would be nice to have a simpler mechanism than that.
If you are only looking for a 'simpler mechanism' to be used by a human and don't need it in some kind of script or so, you might get by with this one:
yum groupinfo '*' | less +/sendmail-cf
Of course, replace sendmail-cf with the package name you're interested in.
You can find a group to which the specified package belongs, by using yum-list-data plugin.
$ sudo yum -y install yum-plugin-list-data
$ yum -C list-groups ftp
Loaded plugins: fastestmirror, list-data
==================== Available Packages ====================
Console internet tools 1 (100%)
list-groups done
Or, if you are not allowed to install the plugin, please save the following script and try to run it with one argument, the name of the package you try to find:
#!/bin/sh
search_name=$1
LANG=C yum grouplist -v | grep "^ " | awk -F'(' '{print $1}' | sed -e 's/^ *//' | while read line
do
if [ "${search_name}" != "" ]; then
yum groupinfo "${line}" | grep -q "^ *${search_name}$"
if [ $? -eq 0 ]; then
echo ${line}
break
fi
fi
done
I don't know about yum, but remember that it sits on top of rpm. The rpm command you're looking for is:
rpm -q --qf %{group} yourRPM
You might want to add a \n at the end, depending on that you are up to:
[root#Niflheim ~]# rpm -q --qf %{group} setarch
System Environment/Kernel[root#Niflheim ~]# rpm -q --qf "%{group}\n" setarch
System Environment/Kernel
[root#Niflheim ~]#

Getting Permission Denied running perl executables

I am running OS X and, basically, I wanted to set up a directory where I could drop some Perl executables and use them without having to type
$perl /this/is/the/path/name.pl
every time I wanted to use one. So I modified my .bash_profile to add a filepath for a directory that sits on my desktop that I want to drop executables in. I modified my .bash_profile by adding
PATH=$PATH:/Users/Wes/Desktop/Perl_dir; export PATH
Now, it finds the Perl files I want but denies me permission to them like so
-bash: /Users/Wes/Desktop/Perl_dir/phylo.pl: Permission denied
How can I fix this? Thank you in advance.
Make sure that the perl script itself is set to be executable. You can do this with a command like this:
chmod +x /Users/Wes/Desktop/Perl_dir/phylo.pl
And then make sure the first line of the script has an appropriate "hash-bang" line to invoke perl, something like:
#!/usr/bin/perl -w
With both of those in place, I think your scripts should start working. (Note: The -w isn't strictly necessary, and may cause warnings in your script. I do suggest it, though, for developing new perl code, since it encourages a certain brand of perl hygiene.)
Apart from setting PATH correctly, you also need to:
make sure files are executable
$ chmod +x /this/is/the/path/name.pl
check your "shebang line", i.e. first line of the script must contain
absolute path to perl interpreter on your machine, like this:
#!/usr/bin/perl
# this will work in Linux distros
To find out the path, use which command:
$ which perl
/path/to/perl
you may need to authorize the chmod using sudo, try this:
sudo chmod u+x program_name
./program_name
If not sudo while chmod, you need to run like this:
sudo chmod u+x program_name
sudo ./program_name

ubuntu server PS, ifocnfig, command not working

i am working on ubuntu server from past few months
and now suddenly ps, ifconfing commnad stop working with below error.
user1#Fb1:/usr/bin$ ps
-bash: /bin/ps: No such file or directory
any suggestions to get this command working back.
What's the output of which ps and ls /usr/bin -al (which are both in /bin also)? Does it work if you gain root privileges, either using sudo ifconfig or sudo su, then ifconfig?
This is possibly an issue with file permissions but it's hard to say without more information.
First use locate to find your ps or ifconfig program:
$ locate ps | grep bin
Also you may try whereis command:
$ whereis ps
If you don't find them, try to search as root user.
i have tried to put all the outputs of different commnads as below
root#Fb1:/usr/bin# whereis ps
ps: /bin/ps /usr/share/man/man1/ps.1.gz
root#Fb1:/usr/bin# ls -lsa ps
16 -rwxr-xr-x 1 root root 15859 2010-05-26 12:21 ps
Something wrong with your $PATH I suspect it doesn't have /sbin .. maybe new software overwrite your $PATH..
normal path should be include this (mebada is my user name)
mebada#T430:~$ echo $PATH
/home/mebada/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin