Find the answer to your Linux question:
Results 1 to 4 of 4
All Gurus I am very new to Linux and im trying to setup an automatic shut down for our linux boxes via our UPS (if there’s a power outage). The ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    2

    Newbie Linux scripting question

    All Gurus

    I am very new to Linux and im trying to setup an automatic shut down for our linux boxes via our UPS (if there’s a power outage). The UPS only allows a batch file to be run so ive come up with this idea...

    I’ve come across plink to allow me to run the Linux command in a batch file:
    plink 10.10.60.30 -l root -pw <password> -ssh /nas/sbin/nas_halt now

    This works fine but after this command it prompts for a yes. Nas_halt command has no auto setting to input yes so it just sits there waiting for input.

    Is there any way I could set this up? e.g getting plink to call a Linux script which calls nas_halt and inputs the yes after?? If so what would this be?

    Any help would be superb.
    Cheers
    Baker0

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    try the command "yes"
    the sun is new every day (heraclitus)

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    11
    A Python script with Pexpect - Noah.org might work?

  4. #4
    Just Joined!
    Join Date
    Nov 2008
    Location
    Virginia, USA
    Posts
    18

    Yes

    This should work:
    Code:
    yes | plink 10.10.60.30 -l root -pw <password> -ssh /nas/sbin/nas_halt now
    If nas_halt is expecting "y" then piping the yes command will work. If nas_halt is expecting "yes' then do:

    Code:
    yes yes | plink 10.10.60.30 -l root -pw <password> -ssh /nas/sbin/nas_halt now

Posting Permissions

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