Results 1 to 2 of 2

Thread: help with expect

  1. #1
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    help with expect

    Hi all.
    I'am trying to create an expect script to temporarily change user to root with su (i cant use sudo)
    and run a series of commands before terminating.

    But i cannot get it to work properly.
    Anyone who can help?

    Code:
    #!/bin/bash
    echo "expect is inside bash"
    
    /usr/bin/expect - << EndMark
    
    spawn su
    expect 'Password:'
    send "xxx\r"
    send "apt-get update\r"
    expect "Building Dependency Tree... Done"
    sleep 2
    send "apt-get -s upgrade |sed '1d' |sed '1d' |head -1 |awk -F ',' '{print $1}' > package.output\r"
    sleep 1
    send "sed 's/packages upgraded/Packages can be upgraded/' package.output > package.output2\r"
    sleep 1
    send "rm package.output\r"
    send "chown nice:nice package.output2\r"
    EndMark
    
    echo "more bash commands"
    exit 0
    Kind regards.

  2. #2
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: help with expect

    Is expect rarely used anymore? Since i find it hard to get help or find useful tutorials on the subject

    No one who can help me?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •