How to ssh from within a bash script?

If you want the password prompt to go away then use key based authentication (described here). To run commands remotely over ssh you have to give them as an argument to ssh, like the following: root@host:~ # ssh root@www ‘ps -ef | grep apache | grep -v grep | wc -l’

Shell script not running, command not found

I am very, very new to UNIX programming (running on MacOSX Mountain Lion via Terminal). I’ve been learning the basics from a bioinformatics and molecular methods course (we’ve had two classes) where we will eventually be using perl and python for data management purposes. Anyway, we have been tasked with writing a shell script to … Read more

Make a Bash alias that takes a parameter?

Bash alias does not directly accept parameters. You will have to create a function. alias does not accept parameters but a function can be called just like an alias. For example: By the way, Bash functions defined in your .bashrc and other files are available as commands within your shell. So for instance you can … Read more

Running programs in parallel using xargs

From the xargs man page: This manual page documents the GNU version of xargs. xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial- arguments followed by items read … Read more

Is there anything in Zsh like .bash_profile?

Yes, it’s called ~/.zshenv. Here’s how I have $JAVA_HOME set in ~/.zshenv: Keep in mind, however, that zsh is not bash, so just ’cause you have to source your .bash_profile every time you open a terminal does not mean that you have to do that with zsh. With zsh, I only have to re-source my ~/.zshenv when I make changes to it, and then only for terminals which … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)