Wednesday, September 11, 2013

svn+ssh upadates(up) and co without password

In many cases people want to automate(scripting) the process for updating/checkout the source code from svn+ssh. For svn+ssh we require to enter password to interactive prompt. To avoid the pass interactive shell and provide password on the command line do following:

If you do not have sshpass installed please install it.

PS: do not export any variable, in the main terminal-shell itself. Export them into the script as exporting it in the main terminal shell may not ask you password at the time of checking in code into repository as well, which certainly nobody wants.

So write a small script 
 line following

#!/bin/bash
cd $local_repo_dir
export SVN_SSH="sshpass -e ssh"
export SSHPASS="ssh_password_to_remote_repository_server"
svn co
svn up


Wednesday, September 4, 2013

finding a screen in which process in running.

If you are working with screen and you have lot of active screens and each one with lot of tabs. If you want to find a screen in which particular process with some pid is running then I could not find any command which does so.  eg:
        What to find screen in which instance of vim is running then there is no inbuilt command to do so.

So Written a small one line complex script for the same.

Just set $CHILD_PID ( or replace the $CHILD_PID) with the pid of process, which is running under screen.

Output will be a line which  shows only  a screen pid (which you could use to log into corrosponding screen)

${ screen -ls | cut -d "." -f  1 | while read PID; do pstree -p $PID | grep "$CHILD_PID" > /dev/null; if [ $? = 0 ]; then echo "$PID" > sam; fi; done } 2>/dev/null; tail sam

After logging into screen you will have to search each and every tab, to find the process.
Process might be running in the backgound so do not forget to do $jobs.