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"
EOD
and 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 06:54 AM..
Reason: Please use code tags
Hi I have two scripts one is Expect and other is shell.
I want to merge Expect code in to Shell script so that i can run it using only one script. Can somebody help me out ?
Order to execute: Run Expect_install.sh first and then when installation completes run runTests.sh shell script.
... (1 Reply)
I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows:
#!/bin/bash
HOST=$1
/usr/bin/expect -c "
spawn ssh -i /root/.ssh/id_rsa root@$HOST
expect -exact "Enter... (3 Replies)
I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues:
set REMOTE "/root/scripts/remote"
...
log_user 1
send_user "Executing remote script as $user...\n"
send_user "Command to execute is: $REMOTE... (1 Reply)
Shell Scipt: temp.sh
su - <$username>
expect pass.exp
Expect script: pass.exp
#!/usr/bin/expect -f
# Login
#######################
expect "Password: " send "<$password>\r"
it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Hi,
Am very new to expect scripting..
Can You please suggest me how to call an expect script inside another expect script..
I tried with
spawn /usr/bin/ksh
send "expect main.exp\r"
expect $root_prompt
and
spawn /usr/bin/ksh
send "main.exp\r"
expect $root_prompt
Both... (1 Reply)
Hi All,
Is there any way to monitor a command inside shell script ? I have a script inside which I have a tar command which zips around 200GB data.
tar zcvf $Bckp_Dir/$Box-BaseBackup-$Day.tar.gz * --exclude 'dbserver_logs/*' --exclude postmaster.pid --exclude 'pg_xlog/*'
I want to... (3 Replies)
Hi all,
I am using the below given sqlplus command in my unix script to invoke a stored procedure which returns a value .It works fine.
RET_CODE=$(/opt/oracle/product/10.2.0.4.CL/bin/sqlplus -S $USER/$PASSWD@$DB_NAME <<EOF
EXEC MY_PKG.MY_SP (:COUNT);
PRINT COUNT;
commit;
... (6 Replies)
hi,
i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (11 Replies)
hi,
i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (1 Reply)