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/

Monday, March 8, 2010

Port forwarding

There are a couple of concepts you need to know before you can understand port forwarding. I'm going to make a couple broad statements that are almost always true. For simplicity lets assume they are true for now.

1.) Every device on the internet has at least one ip address. The IP address is a number that is used to identify a device. For more information on ip addresses refer to our What is an IP Address page.

2.) Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an ip address to a port on an ip address. For more information on ports refer to our What is a Port page.

3.) A port can only be used by one program at a time.

Now that we've got those general concepts out of the way let's talk about NAT. NAT is an acronym for Network Address Translation. NAT takes one ip address and basically breaks it into many ip addresses.

[img]http://www.portforward.com/help/BasicNetwork.jpg[\img]

Here the external ip address is broken into two internal ip addresses. The first ip address "IP Address1" is the gateway. While "IP Address2" is the ip address of the first computer. Take note that the router has two ip addresses. It has the external ip address, and an internal ip address which acts as the gateway for every computer on the network.

[img]http://www.portforward.com/help/NetworkVisibility.jpg[\img]

Excuse my rough drawing. Computers on the internal network can only "see" internal ip addresses. So computers on the internal network can not send data directly to a computer outside of the network. When a computer on the network wants to send data to a computer outside of the network, it sends the data to the gateway. Remember the gateway is the internal ip address of the router. The router then takes this data and sends it out to the computer on the internet. The router sends the data out of the external ip address. The same thing is true of computers on the internet. A computer outside of the network can not "see" a computer inside of the network. They can only "see" and send data to the external ip address of the router. The router must then decide what to do with this data. Lucky for us NAT takes care of most of the work for us. There are some programs that NAT was not designed to work with, those are the programs we need to set up port forwarding for. Okay take a deep breath! We are on to port forwarding.

Now that you understand the general concepts of a network, explaining port forwarding is easy. When a computer on the internet sends data to the external ip address of the router, the router needs to know what to do with the data. Port Forwarding simply tells the router which computer on the local area network to send the data to. When you have port forwarding rules set up, your router takes the data off of the external ip address:port number and sends that data to an internal ip address:port number. Port Forwarding rules are created per port. So a rule set up for port 53 will only work for port 53.

A port can only be used by one program at a time! Think of how this rule interacts with NAT. Well you've only got one external ip address on your router. When computer 1 is using port 500, it is using port 500 on it's internal ip address. If you have set up a port forwarding rule for computer 1 and port 500, the external ip address's port 500 is also in use. This means that you can only use port 500 on one computer on the network at a time. Using port 500 on two computers at the same time would violate the one program rule, and your data would get messed up. Most routers require you to specify an internal ip address to forward ports to, just for this reason. Some do not, so be aware of this. Port Forwarding rules will only work for one computer at a time!

Reference:
http://portforward.com/help/portforwarding.htm