Dark Launch

This is a Dark Launch.

VirtualBox SSH Port 22 Forwarding

To set up SSH access to a VirtualBox VM, you need to forward the appropriate ports.

Open Virtual Box preferences, select the Network tab, select Adapter 1, and click on the "Port Forwarding" button. Add a new rule. Host IP and Guest IP are optional and should be blank. Set Host Port to 2222 and Guest Port to 22.

Note: These Port Forwarding settings take effect immediately in VirtualBox 4, so no need to restart.

Note: Listening on ports 0-1023 requires root permissions, so use a Host Port 1024 and higher. In this case we are using 2222 ("22" + "22").

Connect to the virtual machine via SSH with:

Code
ssh -l myusername -p 2222 localhost
 

Additionally, to transfer files to the virtual machine guest, use the following scp command:

Code
scp -P 2222 /path/to/source/file.txt myusername@localhost:/path/to/destination/
 

Regular Expressions Greedy & Non-greedy Selection; regex

If your regex pattern is too greedy, that is, it finds the largest matching case when you want it to find the smallest matching pattern, use a non-greedy selection.

Replace the greedy quantifier with the corresponding non-greedy version.

"...change * , + , ? , and {} into *? , +? , ?? , and {}? , respectively"
fromto
**?
++?
???
{}{}?

More from the Perl Cookbook http://docstore.mik.ua/orelly/perl/cookbook/ch06_16.htm

How to Include Python Script in Bash Script

To run a multiline python script in a bash shell script from the commandline, do the following

cat <<EOF | python -
import sys
from pprint import pprint
pprint(sys.path)
EOF

This will allow running python code inside a self-contained bash script.