Dark Launch

This is a Dark Launch.

Bash Run a Local Script & Command on Remote Server using SSH

Use ssh to run a local bash script on a remote computer.

Use the following syntax:

Code
ssh user@host sh < myscript.sh
ssh user@host bash < myscript.sh
 

If using bash, include "#!/bin/bash" at the top of myscript.sh and be sure to call `bash' instead of `sh' or you may get commands not found.

OS X bash 'watch' command

To run a command similar to the Linux "watch" command on Mac OSX, do the following:

Code
while :; do your_command; done
 

For example, the following will check the disk usage for the current directory via `du' every two seconds. The `echo -ne "\r"' causing the line to write over itself replacing the existing line.

Code
while :; do echo -ne " "$(du -s .)"\r"; sleep 2s; done
 

Bash add current path to $PATH environment variable

To add the current path the the $PATH environment variable, do the following:

Code
$ PATH=$(pwd):$PATH
 

This will take the current/working directory and add it to $PATH.

Bash run script on web page from url

To run a script or set of commands from a remote website, do the following:

Code
bash < <(curl --silent https://www.example.com/path/to/script.sh)
 

This will cause curl to pull the script and redirect its contents to stdin for bash to parse.

NOTE: be careful with this