treewood

console script using ssh

Posted in Unix by treewood on October 7, 2008

Save the following in a file:

#!/usr/bin/expect -f

set cons [lindex $argv 0]
set port [lindex $argv 1]
spawn ssh  -e ! -l root:$port $cons
#send “\n”
#expect -re “:”
#expect -re “Login”
send “\r”
send “\r”
expect -re “:”
expect -re “#”
expect -re “$”
sleep 5
send “\r”
send “!.\r”
#expect -re “telnet>”
#send “quit\r”

expect eof

Run this command:

bash$ for cons in cons{1..12}; do for i in {7000..7036}; do echo -n “$cons,$i,”; val=`./cons.exp $cons $i 2>/dev/null |grep login |grep -v closed| sed ‘s/login://g’`; echo $val;done ; done

Tagged with:

one way of copying between filesystems

Posted in Unix by treewood on October 7, 2008

bash$ cd /dest_dir

bash$ (cd /top_level_dir ; tar cpf – source_dir ) | tar xvpf -

source_dir/sql/target_v5_p2e_cpc_new.sql
source_dir/sql/target_v4_cpm_new.sql
source_dir/sql/target_v4_cpm.sql
source_dir/crap.php
source_dir/svnmerge.py
source_dir/nte.out

bash$ ls -l /dest_dir/source_dir/sql

-rw-r–r– 1 doobie users  725 2007-08-15 20:19 target_v5_p2e_cpc_new.sql
-rw-r–r– 1 doobie users  739 2007-08-15 20:19 target_v4_cpm_new.sql
-rw-r–r– 1 doobie users  721 2007-08-15 20:19 target_v4_cpm.sql

screen is cool

Posted in Unix by treewood on October 7, 2008

rsomcio@screen1:~> yum list screen
Setting up repositories
Reading repository metadata in from local files
Installed Packages
screen.x86_64                            4.0.2-81               installed

Tagged with:

passwordless ssh with ssh-agent

Posted in Unix by treewood on October 7, 2008

- You must first create a your rsa/dsa keys with ssh-keygen

- Run with exec ssh-agent $SHELL

- Run ssh-add

Tagged with:
Follow

Get every new post delivered to your Inbox.