Problem Executing Firmware Command using Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem Executing Firmware Command using Shell Script
# 1  
Old 01-30-2010
Wrench Problem Executing Firmware Command using Shell Script

Guys,

I have a script that should change one of the configuration Parameter in a http accelerator, this config change which will halt http traffic into device. So I have designed a script which should do these changes. But after executing this script, found that one of the input variable is not getting assigned & the changes are not being implementated into the accelerator device & http traffic is not being halted. So anybody do you have resolution to this issue, for which im going to have my script placed here to help you guys.
Code:
# sample Script to Outrotate the Device in Question
# Script Creation Date 01/21/2010
# Author baraghun

##*******************************************************************************************************
##  **********  FUNCTION USAGE  ***********
##*******************************************************************************************************
##

# Script name without path

BASENAME=`basename $0`

#The INFILE is going to use during the SSH

INFILE=${HOME}/config/inFile.txt

#The changes will write to OUTFILE

OUTFILE=/tmp/outFile.txt

# Functional Usage

usage() {
        echo
        echo "USAGE"
        echo "   "`basename $0`" <device> <disable|enable> "
        echo
        exit
        }
outrotate() {
        echo
        echo "OUTROTATE"
        echo "**********************************************************************"
        echo " Removing your Device `${htACC}` in Question . . . "
        echo "**********************************************************************"
        echo
}

trafficrouting() {

 #Local Variables
      #
       local STATE="$1"
      #

cat << EOF > $INFILE
po1023
pssphrase
config
switch accMode RouteTrafficACC  THIS SECTION is a FIRMWARE COM's
admin  ${STATE}
bye
bye
write memory
y
bye
goodbye
EOF
}

#
#Validate the device name
#
echo $1 | egrep "^(CMOX|PXOM|TXOM)[0-9][0-9][0-9][0-9]\-ra$" > /dev/null 2>&1
if [ $? -ne 0 ]
then
   echo
   echo "Node doesn't exist"
else
   echo "You are lucky enough"
fi
htACC="$1"

# Check the  parameters
#
[ $# -ne 2 ] && usage

# Check the input parameters
#
case $2 in

disable)
                RouteTrafficACC disable
        ;;
enable)
                RouteTrafficACC enable
        ;;
        *)
                usage
        ;;
esac


#
# Apply the changes
#
ssh -T ${htACC} < $INFILE >> $OUTFILE
#
# Remove unused files
#
chmod 777 ${OUTFILE}


Now the issue description is here

1. Function one (usage) is being executed only with first variable (device) for which we do get a response back. But the second variable <disable|enable> is not being recognized.

2. Since issue is with the Function one's 2 variable, function two (outrotate) is not being executed along with the function three's {STATE} & save command is not functioning to disable the device.

Here is the output of the script
Code:
$ ./outrotate.sh CMOX1234-ra disable
You are lucky enough

USAGE
   DPoutrotate.sh <device> <disable|enable>

The Log from outFile

Serial number: 1X23K00C0

ACC># Global configuration mode
ACC>(config)# ACC>[accMode](config)# Modify Multi-Protocol Gateway configuration
ACC>[accMode](config RouteTrafficACC)# Usage: admin <enabled|disabled>
ACC>[accMode](config RouteTrafficACC)# ACC>[accMode](config)# ACC>[accMode]# Unknown command or macro (write memory)
ACC>[accMode]# Unknown command or macro (bye)
ACC>[accMode]# Goodbye

So from the above logs you can figure out where the issue existing. its none other than the admin STATE.

Last edited by Scott; 01-30-2010 at 04:38 AM.. Reason: Please use code tags
# 2  
Old 01-30-2010
You seem to be calling:
Code:
RouteTrafficACC disable

instead of:
Code:
trafficrouting disable

from the case statement? (same for enable)
# 3  
Old 01-30-2010
Yes ,

Because "RouteTrafficACC" itself is a variable in that firmware. If i use "disable" option along with the variable by manually , it disable the http traffic.

According to you I need to use "trafficrouting" as a shell input to the firmware from the case statement, or else i need to replace the case function header with " RouteTrafficACC ".

Correct me if im wrong ..

Thanks in Advance
# 4  
Old 01-30-2010
raghunsi, what I mean is that you have defined a shell function called trafficrouting that never gets called from within the validating case statement. It seems to me you need to call that function so that the command file gets generated that gets used by ssh.

Last edited by Scrutinizer; 01-30-2010 at 05:36 AM..
# 5  
Old 01-30-2010
Do this function variable is dependent on the case statement. Can you just rewrite that function, so that .. let me have a look into that in training environment.
# 6  
Old 01-30-2010
The only variable used by the function is state (enable or disable) . The firmware variable RouteTrafficACC seems to be hard coded in the trafficrouting function.
# 7  
Old 01-30-2010
Yes, firmware variable are only either " enable" or "disable", but variable's in the Firmware are not so hardcoded, so that we cannot able to change. We can change.

We have different scripts that changes the configuration also. but why this is not working .. i need to check now..

I change the function parameter, its working now without any error. But still the concern is its not able to change the Admin state in Firmware .

Need to debug now .. with firmware as well as script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing 'exit' command from shell script

Hi, I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script. My intension is to execute... (4 Replies)
Discussion started by: Mahesh Desai
4 Replies

2. UNIX for Dummies Questions & Answers

Cron shell script not executing diskutil command

I'm trying to learn how to use cron for repetative tasks. I have an external disk that needs to be unmounted and remounted every hour due to some problems that a backup utility (specifically, TimeMachine) is having repeatedly accessing the device. I've created a shell script that will find the... (3 Replies)
Discussion started by: illuminate
3 Replies

3. UNIX for Dummies Questions & Answers

Executing a tar command with the --exclude option in a Debian shell script.

Hi All, I am trying to execute the following tar command with two --exclude options to suppress extract of the two directories specified. Do I need to single quote the directory paths ?? Many thanks for your help. The relevant code excerpt from the script is: cd /var/www/${SITE} ... (7 Replies)
Discussion started by: daveu7
7 Replies

4. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

5. Shell Programming and Scripting

Problem in executing sed command

Hi, Input: XX = to_date ('9999-12-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS') Required output: XX=to_date (\'9999-12-31 23:59:59\', \'YYYY-MM-DD HH24:MI:SS\') Regards Akshu (3 Replies)
Discussion started by: akshu.agni
3 Replies

6. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

7. Shell Programming and Scripting

Problem with executing a shell script through the cron

Hi, I have a shell script as below: ORACLE_HOME=/usr/local/opt/oracle/product/dev export ORACLE_HOME PATH=$PATH:$ORACLE_HOME/bin:/usr/bin export PATH OUTFILE=/export/home/`basename $0`.out export OUTFILE export IDEN df -k . | tail -1 | read a b c d e f echo $a >> $OUTFILE echo $b... (4 Replies)
Discussion started by: Abhinav Pandey
4 Replies

8. Programming

c executing shell problem

Hello im geting error here: #include <stdlib.h> #include <stdio.h> using namespace std; int main (int argc, char *argv) { char user; string command; cin << user; command = printf ("grep '%s' /etc/shadow", user); system (command.c_str()); } return 0; } it should search shadow... (6 Replies)
Discussion started by: velniaszs
6 Replies

9. AIX

Having problem with executing shell script to get the pid details!

Hello Everyone, I am new to shell scripting and also i am very new to AIX machine I have a question. I have shell script which contains the follwing "ps -e |grep $1 echo $2" i run this schell script by doing this ./startSehllscript 3444 passed with two parameters . Accroiding my... (4 Replies)
Discussion started by: swati
4 Replies

10. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies
Login or Register to Ask a Question