Wednesday, October 14, 2009

To export your PuTTY and WinSCP sessions

You can export your settings for these apps from regedit:

PuTTY:

HKEY_CURRENT_USER\Software\SimonTatham

WinSCP:

HKEY_CURRENT_USER\Software\Martin Prikryl

Tuesday, October 13, 2009

Copying and pasting in screen

When you're in screen and want to copy something...

Go
<Ctrl>-A [
Then move to where you want to mark, using your vi keys hjkl or the arrow keys.
Press
<Enter>
to set the first mark.
Select the block you want to copy by moving to the second mark
then press
<Enter>
to copy the selected text to the buffer

Then to use the selected text...

Say you want to cat it into a file...


$ cat > file


Then go
<Ctrl-A> ]
to paste.

This also lets you go back up into your scrollback.

http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/ is a good HOWTO for this.


$ cat ~/.screenrc
vbell_msg '*ding*'
vbell off
defscrollback 20000
scrollback 20000
compacthist on

Monday, October 12, 2009

protocol error: mtime.sec not delimited

If you get an error saying:


protocol error: mtime.sec not delimited


When you are using scp to send files to a machine...

Check the login process on that machine to see what messages are being echoed to STDOUT when you login.
If you can get rid of the message (e.g. by not running fortune or doing 'echo "blah"') then the error should go away.

If it's something you want to run on an interactive login, then you could put a test around it to only run it then...

e.g.


if [ $TERM == "xterm" ]; then
fortune -s
fi

Thursday, October 01, 2009

vi change on matching lines

If you'd like to do something globally on lines that match a string,
without needing to do anything to the string itself...

e.g. find all lines matching <img src=".*> and append </a>


:g/<img src=".*>/s%$%</a>%


This says:

globally match <img src=".*>

and on the matching lines substitute </a> for $

Tuesday, September 22, 2009

~/.ssh/config

The fields you most often need in ~/.ssh/config are...


Host HOSTNAME
User USERNAME
HostName IP_ADDRESS (or hostname.fqdn)


Not to mention the proxy stuff below.

Tuesday, September 15, 2009

Extracting files from Solaris packages

How to extract files from a DaTaStReAm package without installing the package on the system:

You use pkgtrans to convert a datastream format package to file system format.


$ pkgtrans gzip-1.3.12-sol26-sparc-local .

Thursday, August 06, 2009

Debian Lenny in qemu on Windows

http://homepage3.nifty.com/takeda-toshiya/qemu/

Create an image to install into:

qemu-img.exe create -f qcow qemu_disk.img 3G

Download install image:

http://www.debian.org/CD/netinst/


Copy and change qemu-win.bat

To boot the install image with:
qemu.exe -L . -m 128 -hda qemu_disk.img -soundhw all -localtime -M -cdrom debian-503-i386-netinst.iso

Then to run normally, remove the -cdrom part.

I have also used: -m 256 -cpu pentium3 -M pc -no-reboot -no-acpi -no-kqemu

To do this I copied qemu-win.bat to a new batch file, and edited that to suit my needs and use that to start qemu.

There maybe a few errors when it boots, but nothing serious - and I can run it on a machine where I don't have admin, where I can't install VirtualBox or similar.

If you add:

-redir tcp:22::22
You can ssh into localhost to get into the machine.
-redir tcp:2222::22 if 22 is already in use...

Other links:
http://lassauge.free.fr/qemu/
http://www.davereyn.co.uk/download.htm ?

Friday, July 17, 2009

rolling back a commit with git

Get the hash of the version you want...


$ git log


Check out the version into the current dir:


git checkout 45a5b1aa137c07b15f820f49762feb7ec068b3f8 .


http://stackoverflow.com/questions/373812/rollback-file-to-much-earlier-version

Tuesday, March 03, 2009

Dead ringer...

How to disable bells all over the place...

To turn off that annoying flash (that lags your session) in vim:

In .vimrc


set vb t_vb= " Turn off visual bell


General beeps...

In .inputrc


set bell-style none


In ~/.bash_profile (or /etc/profile or .bashrc or somewhere)


setterm -blength 0


In X Window:


$ xset b off


To turn it on again use:


$ xset b on


For less

In ~/.bash_profile:


export LESS="-q"