From: Sooraj S on
Hi,

I want to login to a remote machine(my_machine) and check if my
filesystem (xpr) is mounted or not. But my script did not work fine.
(I have mounted my file system before running this).

script-1
---------

#!/usr/bin/expect -f
proc usrlogin {expected cmd} {
expect {
"$expected" {
send $cmd
}
}
}

if [catch {spawn telnet my_machine} error] {
send_user "$error"
} else {
usrlogin "login:" "user\r"
usrlogin "Password:" "\r"
if {[file exists "/mnt/sooraj/xpr"]} {
puts "\n***carry on man***\n"
}
}


I wrote one more script excluding the login part and run on the remote
machine directly(my_machine) and it worked.

script-2
--------

#!/usr/bin/expect -f

if {[file exists "/mnt/sooraj/xpr"]} {
puts "\n***carry on man***\n"
}

Can any one pls resolve this...
From: Bruce on
Sooraj S wrote:
> Hi,
>
> I want to login to a remote machine(my_machine) and check if my
> filesystem (xpr) is mounted or not. But my script did not work fine.
> (I have mounted my file system before running this).
>
> script-1
> ---------
>
> #!/usr/bin/expect -f
> proc usrlogin {expected cmd} {
> expect {
> "$expected" {
> send $cmd
> }
> }
> }
>
> if [catch {spawn telnet my_machine} error] {
> send_user "$error"
> } else {
> usrlogin "login:" "user\r"
> usrlogin "Password:" "\r"
> if {[file exists "/mnt/sooraj/xpr"]} {
> puts "\n***carry on man***\n"
> }
> }
>
>
> I wrote one more script excluding the login part and run on the remote
> machine directly(my_machine) and it worked.
>
> script-2
> --------
>
> #!/usr/bin/expect -f
>
> if {[file exists "/mnt/sooraj/xpr"]} {
> puts "\n***carry on man***\n"
> }
>
> Can any one pls resolve this...

file exists is a tcl command that is run in your main script which is
running on your local host. if you want to check things on you remote
host you need to interact with the remote host via the program you
spawned - i.e. use send/expect (like you did for you login stuff)

so you donlt need a tcl command to check for a directoy - you just need
to send a unix command and look at the results (with expect) something
like

send "file /mnt/sooraj/xpr"
expect {
"No such file or directory" {
puts "Not mounted"
}
": directory" {
puts "Good to go"
}
}



Bruce