Wednesday, May 30, 2007

Getting shell script variable values

Here is the problem

bash-2.05# cat test1.sh
ATM_PIN="123"
echo "Environment variables" > out.log
env >> out.log
echo $ATM_PIN

bash-2.05# sh test1.sh
123

bash-2.05# cat out.log |grep -i atm
bash-2.05#

While debugging a shell script, if the values of the variables are required in an intermittent state of the shell script execution use the -a option.

bash-2.05# sh -a test1.sh
123
bash-2.05# cat out.log |grep -i atm
ATM_PIN=123
bash-2.05#

Thursday, May 17, 2007

Configuring rsh service on Linux

By default the rsh service is not enabled (obviously).

So here are the steps

1. Check if the rpms are installed. (else use the cd's to install)
redhat# rpm -qa|grep rsh
rsh-server-0.17-25.4
rsh-0.17-25.4
redhat#
2. In /etc/xinetd.d/rsh set disable = no
3. Edit the following files

redhat# cat /etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
ALL : localhost/hostA
redhat# cat /etc/hosts.equiv
localhost
redhat# cat .rhosts
+ user1

4. /etc/init.d/xinetd restart
5. Test the above
redhat# rsh localhost
redhat#
//password less login to remote machine

Disclaimer: more secure services like ssh are recommended than services like rsh.