Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I'm having trouble getting a script to work. If I enter the following on the command line: (Note: I've had to replace the "at" character to get this post ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    2

    having trouble getting a script to work

    Hi,


    I'm having trouble getting a script to work. If I enter the following on the command line: (Note: I've had to replace the "at" character to get this post onto the forum).

    Code:
    /Applications/sshfs/bin/mount_sshfs user*at*192.168.0.1: /Users/me/sshfs/harddisk
    ... and then enter my password manually, it works fine and the sshfs volume mounts to my desktop. I then tried to write a script so I don't need to type my password in:

    Code:
    #!/usr/bin/expect
    spawn /Applications/sshfs/bin/mount_sshfs user*at*192.168.0.1: /Users/me/sshfs/harddisk
    expect "*?assword:"
    send "1234\r"
    expect eof
    exit 0
    I've saved this to a file called go.sh. If I launch ./go.sh from the same command prompt as above, it executes without causing any errors, but the volume doesn't mount.

    Any clues?

  2. #2
    Just Joined!
    Join Date
    Oct 2008
    Posts
    44
    I'm no expert, but I don't know what the "spawn" command is. I don't seem to be able to find it here. Have you tried the script without it?

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi, GMorris.
    Quote Originally Posted by GMorris View Post
    I'm no expert, but I don't know what the "spawn" command is. I don't seem to be able to find it here. Have you tried the script without it?
    This appears to be an expect script, not a shell script ... cheers, drl
    Code:
           spawn [args] program [args]
                 creates a new process running program args.  Its stdin, stdout
                 and stderr are connected to Expect, so that they may be read and
                 written by other Expect commands.  The connection is broken by
                 close or if the process itself closes any of the file
                 identifiers.
    
    -- excerpt from man expect, q.v.
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. #4
    Just Joined!
    Join Date
    Oct 2008
    Posts
    44
    Ahh, no wonder I didn't catch that!

    Quote Originally Posted by drl View Post
    Hi, GMorris.

    This appears to be an expect script, not a shell script ... cheers, drl
    Code:
           spawn [args] program [args]
                 creates a new process running program args.  Its stdin, stdout
                 and stderr are connected to Expect, so that they may be read and
                 written by other Expect commands.  The connection is broken by
                 close or if the process itself closes any of the file
                 identifiers.
    
    -- excerpt from man expect, q.v.

  5. #5
    Just Joined!
    Join Date
    Jan 2011
    Posts
    2
    Found an easier way:

    Code:
    echo password | sshfs etc. -o password_stdin

    Hope this helps someone!

Posting Permissions

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