Tuesday, April 6, 2010

cygwin

Backspace problem with vim in cygwin:
a) Make sure you are in nocompatible mode, ":set nocp"
b) Check your 'backspace' setting. ":set bs=2" should allow you to
backspace normally in insert mode.




References:
http://comments.gmane.org/gmane.editors.vim/33436

Thursday, March 25, 2010

Firefox

Firefox shortcuts:

Back one Page: "Backspace"
Go Down One Screen : "PageDown" or "Spacebar"
Go Up One Screen: "PageUp" or "Shift+Spacebar"

References:
http://www.7is7.com/software/firefox/shortcuts.html

Monday, March 22, 2010

Pine

Pico Editor

Pico, short for Pine Composer, started life as the built-in editor for the Pine email program. Lots of people use Pico as a text editor because they also use the friendly Pine program for email.

PINE

By default, Pine automatically checks for new mail every 2.5 minutes. (You can change this time interval with the mail-check-interval option in the SETUP CONFIGURATION screen.) Some system administrators may have globally modified this interval.

When viewing the FOLDER INDEX, you can force Pine to check for new mail by pressing ^L, or if on the last item in the Index, by pressing "N". The eXpunge command will also force a new-mail check. If you would like to have some visual indication of when Pine is checking for new mail, set the enable-mail-check-cue feature and watch for an asterisk to flash in the upper-left-hand corner of the screen. (Two asterisks mean that Pine is check-pointing --saving state changes in-- your INBOX.)

jump to start of line : ctrl-a

jump to end of line : ctrl-e

page-down : ctrl-v

page-up : ctrl-y

jump to bottom : ctrl-w ctrl-v

jump to top : ctrl-w ctrl-y

set mark (for copy) : ctrl-^

cut line (or marked text) : ctrl-k

paste : ctrl-u

delete : ctrl-d

backspace : Backspace

delete : backspace (yup, you read that right, depends on your terminal settings)

wrap text : ctrl-j

search : ctrl-w

replace : (NOTE pico needs to be started with -b for this to work) ctrl-w ctrl-r

spell-check : ctrl-t (note that pico needs to be started with -s ispell for this to work), I add this line to my .profile: alias pico='pico -s ispell' so that this can be done automatically.

get cursor position - ctrl-c

insert an external file : ctrl-r

exit (will prompt to save) : ctrl-x

sort threads : $ h

delete/mark as read all messages : ; then a then a then *


General config in .pinerc:

user-domain=domain.com
default-fcc="{email.domain.com/user=username}Sent Items"
postponed-folder={email.domain.com/user=username}Drafts
rsh-open-timeout=0
inbox-path={email.domain.com/user=username}INBOX
smtp-server=outbound.domain.com


References:

http://www.blogger.com/post-create.g?blogID=5997165761357298829

http://www.washington.edu/pine/


Friday, March 19, 2010

GNU Screen

 Screenrc

caption always
#caption string "%{kw}%-w%{wr}%n %t%{-}%+w"
caption string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "

Ctrl-a : -- will take you to the GNU SCREEN command mode(vim kind of ex mode)

Ctrl-a :altscreen on/off -- To clear/not screen up on exiting from vim/less/man
Ctrl-a :number -- To renumber current terminal with newer one, incase a terminal exist with new number,
                  it   will take the current terminal number.
Ctrl-a :A -- To rename the current window
Ctrl-a :hardcopy -h [filename] -- copy entire contents of scrollback buffer
Ctrl-a :H       Begins/ends logging of the current window to the file "screenlog.n".
Ctrl-a :log [on|off] -- Begins/ends logging of the current window to the file "screenlog.n".
Ctrl-a :logfile filename -- Setting filename for logging.
Ctrl-a :logfile flush [secs] --  is used to set delay between each write to the logfile, by default it’s 10 seconds.

Configuring the Scrollback Buffer

By default, the scrollback buffer only keeps the last 100 lines of text, which is not enough for my typical interaction with Screen. I’ve found a setting of 5000 lines to be more than adequate for my usage. The number of scrollback lines can be configured in your $HOME/.screenrc file, by adding the following line:
defscrollback 5000
This sets the scrollback to 5000 lines.
You can also override this default value when starting screen using the -h [num] option, where num is the number of scrollback lines.
Finally, if you want to change the number of lines of scrollback for a single window, using the “scrollback” command. Hit C-a (Ctrl-A) : to go to the Screen command line and type scrollback num, where num is the number of scrollback lines.
In screen search to turn off case:
C-a :ignorecase off/on
Problem: GNU got struck because of mistakenly pressed "ctrl-s"
Solution: Ctrl+s “tells the system not to send any more data to the screen until a ctrl-q is pressed”. so pressing ctrl-q will solve the problem here :-)
References:
https://bbs.archlinux.org/viewtopic.php?id=55618
https://wiki.archlinux.org/index.php/GNU_Screen
http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/
http://www.gnu.org/software/screen/manual/screen.html
http://aperiodic.net/screen/commands:start 
http://superuser.com/questions/137714/using-screen-commands-like-less-and-man-dont-clear-the-screen-afterwards/137751#137751 
http://serverfault.com/questions/244294/gnu-screen-how-to-re-order-windows-change-the-scroll-shortcut-and-modify-th 
https://github.com/saltycrane/homedir/blob/master/etc/.screenrc

Thursday, March 18, 2010

Finding serial number of PC

On windows:
1. On your Windows PC, activate WMIC (Windows Management Instrumentation Command-line). Open the "Start" menu and choose the "Run" option. In the dialogue box that is opened, type "wmic." If this is the first time you have used WMIC, Windows will install it automatically.
2.Type the serial number request into WMIC. When installed, WMIC will display a command prompt, into which various commands can be typed into. The command to retrieve your PC's serial number is "bios get serialnumber."





Reference:
http://www.ehow.com/how_5794011_serial-number-pc-windows.html

Monday, March 15, 2010

Proxy Server

A proxy server, also known as a "proxy" or "application level gateway", is a computer that sits between a client and a server to intercept requests. There are several uses of a proxy server, but the most common is to speed network traffic by caching pages or files that are requested often. By doing so, the proxy server can deliver the request quickly, only polling the server when required. In this way, a proxy server not only speeds up network traffic, but also relieves server load. Major Internet hubs and Internet Service Providers (ISPs) employ dozens of proxy servers.

With proxy server an enterprise can ensure security, administrative control, and caching service.

A proxy server is associated with or part of a gateway server that separates the enterprise network from the outside network and a firewall server that protects the enterprise network from outside intrusion.

Some proxy servers are a group of applications or servers that block common Internet services. For example, an HTTP proxy intercepts web access, and an SMTP proxy intercepts email.

Note: Do not confuse a proxy server with a NAT (Network Address Translation) device. A proxy server connects to, responds to, and receives traffic from the Internet, acting on behalf of the client computer, while a NAT device transparently changes the origination address of traffic coming through it before passing it to the Internet.

For those who understand the OSI (Open System Interconnection) model of networking, the technical difference between a proxy and a NAT is that the proxy server works on the transport layer (layer 4) or higher of the OSI model, whereas a NAT works on the network layer (layer 3).



References:
http://www.wisegeek.com/what-is-a-proxy-server.htm
http://whatis.techtarget.com/definition/0,,sid9_gci212840,00.html
http://kb.iu.edu/data/ahoo.html

Thursday, March 11, 2010

expect

Expect keywords:
spawn
send
expect
interact
$expect_out(0,string)
$expect_out(buffer)
set timeout
expect eof


EXPECT EXAMLES: 
1. Pattern matching 
#!/usr/bin/expect
set timeout 15
expect "hi"  { send "You said hi\n" } \
     "hello"  { send "Hello to you\n" } \
     "bye"    { send "Goodbye\n" } \
     timeout  { send "I’m fed up\nbye\n" }


2. Expect script to connect to ssh server iteratively:
#!/usr/bin/expect -f
set timeout 3600
set iter 50
for {set i 1} {$i <= $iter} {incr i} {
        puts "SSh Iteration : $i \n"
        spawn ssh admin@192.168.1.4
        expect "Password:"
        send "mail4567\n"
        close $spawn_id
        after 900
}
 

3. Expect example
$ cat test.sh
#!/bin/sh
echo "Whats your name"
read name
echo "Hello $name"Here is expect script "test.exp" to automate the above script#!/usr/bin/expect -f

spawn ./test.sh

expect "Whats your name"
send "RAJA\r"
interact$ expect test.exp
spawn ./test.sh
Whats your name
RAJA
Hello RAJA

4. attaching to gdb server
#!/usr/bin/expect                                                              
spawn telnet 10.64.70.21                                                      
expect "$ " {send "gdbserver :1234 --attach \$(pgrep wncd)\n"}                 
interact


5. Attaching to gdb client:
#!/usr/bin/expect                                                              
spawn /auto/binos-tools/bin/mcp_gdb  -r $env(PWD) -p $env(PWD)/linkfarm/x86_64_cge7/usr/binos/bin/wncd
expect "\(gdb\) " {send "target remote 10.64.70.21:1234\n"}                   
interact  







References:

http://www.tcl.tk/man/expect5.31/expect.1.htmlhttp://www.tcl.tk/man/expect5.31/expect.1.html
http://unstableme.blogspot.com/search/label/Expect

http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html
http://www.thegeekstuff.com/2010/10/expect-examples/http://www.thegeekstuff.com/2010/10/expect-examples/