Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

http://www.hrum.org http://debedb.blogspot.com/

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

One-click connect from cygwin to full-screen Linux (X stuff required)

Optional: execute the following once (see http://hacks.oreilly.com/pub/h/66 for
details), to avoid typing in the password.

set LINUX_HOST=mylinuxhost
ssh-keygen -t rsa
ssh %USERNAME%@%LINUX_HOST% "mkdir .ssh; chmod 0700 .ssh"
bash -c 'scp ~/.ssh/id_rsa.pub %LINUX_HOST%:.ssh/authorized_keys2'


Now, if you save the following as a BATCH file, you can just click it
to connect to fullscreen Linux:

set LINUX_HOST=mylinuxhost
start /min xinit 
xhost +%LINUX_HOST%
ssh %LINUX_HOST% "declare -x DISPLAY=%COMPUTERNAME%:0; echo $DISPLAY;gnome-session"'


NOTES:
1.
Sometimes xhost + does not execute in time. O well. Just close
all windows that got opened and try again.

2.
If you didn't do the step one (ssh keys), you will be prompted
to enter the linux password; this increases the chances of the above
error.

3.
The single terminal window appearing in the Linux desktop is in fact
a window from your PC.

Lowercasing a string in BAT files

Using this silliness, here's an example of BAT file that will
lower-case a string given as an argument.

echo>%1
dir /b/l %1>lower.tmp
set /p result=<lower.tmp
echo %result%


Saving this as lower.bat, I run

lower "HELLO WORLD"


and get

hello world

as a result

Using Unix shell's backquote functionality in DOS/Windows batch files

In BAT files, an equivalent of a Unix shell's
set foo `bar`


can be accomplished as

bar>bar.tmp
set /p foo=<bar.tmp


If you're spoiled by Unix's notion of
true pipes, note that the following:

bar | set /p foo=


does not work.
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS