Find the answer to your Linux question:
Results 1 to 2 of 2
The program is given below #!/usr/bin/expect -f #!/bin/sh set force_conservative 0 ;# set to 1 to force conservative mode even if ;# script wasn't run conservatively originally if {$force_conservative} { ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Posts
    1

    Exclamation Error throwing during bash scripting


    The program is given below
    #!/usr/bin/expect -f
    #!/bin/sh
    set force_conservative 0 ;# set to 1 to force conservative mode even if
    ;# script wasn't run conservatively originally
    if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
    sleep .1
    exp_send -s -- $arg
    }
    }
    a=xxx.xxx.xxx.xxx
    set timeout -1
    spawn ssh -l admin -i /root/sys.dat $a uptime
    match_max 100000
    expect -exact "Enter passphrase for key '/root/sys.dat': "
    send -- "password\r"
    expect eof

    -----------------------------------------------------

    I am logging in as admin and i want to check the uptime that i have to make it for many servers.
    If i execute the program it shows the following error

    root@localhost#./login
    invalid command name "a=xxx.xxx.xxx.xxx"
    while executing
    "a=xxx.xxx.xxx.xxx"
    (file "./login" line 45)


    Please give me a solution and thanks for the support in advance

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    I don't actually know Expect, but my quick Wikipedia research tells me that the problem is probably that you are using the wrong variable syntax for $a. I don't know what the proper syntax is, but Expect is somehow reading "a=xxx.xxx.xxx.xxx" as an Expect command (which obviously doesn't exist) rather than a variable declaration.

Posting Permissions

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