|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can i use if else inside expect command in shell script?
hii,, I am trying to automate jira. during my scripting using bash script, in the terminal i got the terminal message like this: Code:
"Configure which ports JIRA will use. JIRA requires two TCP ports that are not being used by any other applications on this machine. The HTTP port is where you will access JIRA through your browser. The Control port is used to Startup and Shutdown JIRA. Use default ports (HTTP: 8080, Control: 8005) - Recommended [1, Enter], Set custom value for HTTP and Control ports [2]" here i want to change the port if i have entered a string for that port or just continue with the default.if i am trying with the custom values, i will get the message like that, i want to type enter the custome values there. all these process iam doing with expect and i getting done when i go without changing the port values.my succeess code is as below: Code:
/usr/bin/expect <<EOD spawn sudo ./atlassian-jira-5.1-x64.bin expect "This will install JIRA 5.1 on your computer." send "\r" expect "Choose the appropriate installation or upgrade option." send "\r" expect "Where should JIRA 5.1 be installed?" send "\r" expect "Choose the appropriate installation or upgrade option." send "\r" expect "Default location for JIRA data" send "\r" expect "Configure which ports JIRA will use." send "\r" expect "JIRA can be run in the background." send "\r" EOD but now when i tried to change that ports , my code is: Code:
/usr/bin/expect <<EOD
spawn sudo ./atlassian-jira-5.1-x64.bin
expect "This will install JIRA 5.1 on your computer."
send "\r"
expect "Choose the appropriate installation or upgrade option."
send "\r"
expect "Where should JIRA 5.1 be installed?"
if [ -z "$location" ]; then
send "\r"
else
send "$location\r"
fi
expect "Choose the appropriate installation or upgrade option."
send "\r"
expect "Default location for JIRA data"
if [ -z "$default_locaton" ]; then
send "\r"
else
send "$default_locaton\r"
fi
expect "Configure which ports JIRA will use."
if [ -z "$config_port" -a -z "$control_port" ]; then
send "\r"
elif [ -n "$config_port" -a -z "$control_port" ]; then
send "2\r"
expect "HTTP Port Number"
send "$config_port\r"
expect "Control Port Number"
send "\r"
elif [ -z "$config_port" -a -n "$control_port" ]; then
send "2\r"
expect "HTTP Port Number"
send "\r"
expect "Control Port Number"
send "$control_port\r"
elif [ -n "$config_port" -a -n "$control_port" ]; then
send "2\r"
expect "HTTP Port Number"
send "$config_port\r"
expect "Control Port Number"
send "$control_port\r"
fi
expect "JIRA can be run in the background."
send "\r"
EODand iam getting the error as: Code:
invalid command name "-z"
while executing
"-z "/opt/atlassian/jira/jiranew" "
invoked from within
"if [ -z "/opt/atlassian/jira/jiranew" ]"Please give mea solution ASAP. thanks...
Last edited by Scott; 07-27-2012 at 05:54 AM.. Reason: Please use code tags |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
That's just not how if statements work in expect, if I'm reading it right. Most of your checks come down around like the below: I don't have expect handy this second, but I think this would be right Code:
if {0 == [llength $config_port]} {
send "Something\r"
}You just need to adjust how you're doing if statements - bourne syntax isn't right for an expect/tcl script. |
| The Following User Says Thank You to Vryali For This Useful Post: | ||
nithinfluent (07-30-2012) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to monitor a command inside shell script | sussus2326 | Shell Programming and Scripting | 3 | 01-27-2011 05:41 AM |
| Error while using sqlplus command inside 'if' condition in an unix shell script | Shri123 | Shell Programming and Scripting | 6 | 11-01-2010 10:09 PM |
| how to run shell script inside expect script? | robbiezr | Shell Programming and Scripting | 1 | 05-06-2009 12:58 PM |
| how to redirect the output of a grep command to a file inside a shell script | kripssmart | Shell Programming and Scripting | 11 | 06-19-2008 07:28 AM |
| how to get the output of a grep command to a file inside a shell script | kripssmart | UNIX for Dummies Questions & Answers | 1 | 06-16-2008 03:12 PM |
|
|