Skip to main content
added 99 characters in body
Source Link
klerk
  • 2.9k
  • 2
  • 19
  • 16

I have bash script and inside it part with expect code:

#!/bin/bash
set -ex

funct()
{
pass3="some_pass"

    expect -c "
    spawn su - oracle
    expect "Password:"
    send \"$pass3\n\"
    interact
    "
}
funct

var_ulimit=`ulimit -Ha |grep "open files" |awk '{print $4}'`
echo $var_ulimit

when i execute the script ./script.sh, part with exepct work's ok i have switched to correct user. Problem is that script stop's at that point when executed from shell. Only when i do exit from shell bash script continues. Is it possible to tune expect part of the script to resolve thisproceed with the rest of the bash script and to preserve shell for the rest of the script when do su - oracle?

Thnx

I have bash script and inside it part with expect code:

#!/bin/bash
set -ex

funct()
{
pass3="some_pass"

    expect -c "
    spawn su - oracle
    expect "Password:"
    send \"$pass3\n\"
    interact
    "
}
funct

var_ulimit=`ulimit -Ha |grep "open files" |awk '{print $4}'`
echo $var_ulimit

when i execute the script ./script.sh, part with exepct work's ok i have switched to correct user. Problem is that script stop's at that point when executed from shell. Only when i do exit from shell bash script continues. Is it possible to tune expect part of the script to resolve this?

Thnx

I have bash script and inside it part with expect code:

#!/bin/bash
set -ex

funct()
{
pass3="some_pass"

    expect -c "
    spawn su - oracle
    expect "Password:"
    send \"$pass3\n\"
    interact
    "
}
funct

var_ulimit=`ulimit -Ha |grep "open files" |awk '{print $4}'`
echo $var_ulimit

when i execute the script ./script.sh, part with exepct work's ok i have switched to correct user. Problem is that script stop's at that point when executed from shell. Only when i do exit from shell bash script continues. Is it possible to tune expect part of the script to proceed with the rest of the bash script and to preserve shell for the rest of the script when do su - oracle?

Thnx

Source Link
klerk
  • 2.9k
  • 2
  • 19
  • 16

how to continue bash script execution when expect part is finished

I have bash script and inside it part with expect code:

#!/bin/bash
set -ex

funct()
{
pass3="some_pass"

    expect -c "
    spawn su - oracle
    expect "Password:"
    send \"$pass3\n\"
    interact
    "
}
funct

var_ulimit=`ulimit -Ha |grep "open files" |awk '{print $4}'`
echo $var_ulimit

when i execute the script ./script.sh, part with exepct work's ok i have switched to correct user. Problem is that script stop's at that point when executed from shell. Only when i do exit from shell bash script continues. Is it possible to tune expect part of the script to resolve this?

Thnx