Results 1 to 2 of 2

Thread: Scripting help?

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Scripting help?

    Hi all,
    Im trying to automate some root type activities.
    The code imediately below seems to work fine, when I run the script, I am left with an open root terminal session.
    Code:
    #!/usr/bin/expect
    spawn sudo -i
    expect ":"
    send "MyPassword\r"
    expect "#"
    interact
    The problem comes when I try to add root functions, like shutting down the computer. I'm not sure if there is a timing issue or what is going on, but, I'm stumped.



    Code:
    #!/usr/bin/expect
    spawn sudo -i
    expect ":"
    send "MyPassword\r"
    expect "#"
    puts "Shutting down computer "
    send "shutdown -h now\r"
    also, if there is an easy way to do this without expect, I'd like to know what it is.
    ~Conradin~

  2. #2
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripting help?

    Ok i got it!
    Code:
    #!/usr/bin/expect
    spawn sudo -i
    expect ":"
    send "MY_Password\r"
    expect "#"
    puts "Shutting Down Ethernet connection 0 "
    send "\r"
    send "ifdown eth1\r"
    expect "configured"
    puts "Shutting down computer "
    send "\r"
    send "shutdown -h now\r"
    interact
    ~Conradin~

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
  •