expect

Hi,

I'm creating an scripy that uploads several files to an webdav server. I'm using cadaver to acomplish this.

I use expect to try and catch login, but it does'nt work.
When I execute is from an external file is works, however i can't give an username and password.

#/usr/bin/expect -f /home/jeroen/expect

When I execute it in the script is does'nt work

#!/bin/bash -vx


echo "Vul uw gebruikersnaam in"
+ echo 'Vul uw gebruikersnaam in'
Vul uw gebruikersnaam in
while true
        do
        read USER
     break
done
+ true
+ read USER
*****
+ break

echo "Vul uw wachtwoord in"
+ echo 'Vul uw wachtwoord in'
Vul uw wachtwoord in
while true
        do
        read PASS
     break
done
+ true
+ read PASS
********
+ break


#/usr/bin/expect -f /home/jeroen/expect

VAR=$(expect -c "
spawn /usr/bin/cadaver http://*****
expect "Username:"
send "*******\n"
expect "Password:"
send "*******\n"
expect "dav:"
send "cd ICT/test\n"
expect "dav:"
send "lcd /home/jeroen/Desktop/mijnwerk\n"
expect "dav:"
send "mput *\n"
expect "dav:"
send "quit\n"
")
expect -c "
spawn /usr/bin/cadaver http://**********
expect "Username:"
send "********\n"
expect "Password:"
send "********\n"
expect "dav:"
send "cd ICT/test\n"
expect "dav:"
send "lcd /home/jeroen/Desktop/mijnwerk\n"
expect "dav:"
send "mput *\n"
expect "dav:"
send "quit\n"
")
expect -c "
spawn /usr/bin/cadaver http://*************
expect "Username:"
send "********\n"
expect "Password:"
send "*******\n"
expect "dav:"
send "cd ICT/test\n"
expect "dav:"
send "lcd /home/jeroen/Desktop/mijnwerk\n"
expect "dav:"
send "mput *\n"
expect "dav:"
send "quit\n"
"
++ expect -c '
spawn /usr/bin/cadaver http://**********
expect Username:
send ******n
expect Password:
send ********n
expect dav:
send cd' 'ICT/testn
expect dav:
send lcd' '/home/jeroen/Desktop/mijnwerkn
expect dav:
send mput' '*n
expect dav:
send quitn
'
couldn't read file "ICT/testn
expect dav:
send lcd": no such file or directory
+ VAR='spawn /usr/bin/cadaver http://********.nl/
Authentication required on server `********'\'':
Username: ********

This is the script I have.

#!/bin/bash -vx


echo "Vul uw gebruikersnaam in"
while true
        do
        read USER
     break
done

echo "Vul uw wachtwoord in"
while true
        do
        read PASS
     break
done


#/usr/bin/expect -f /home/jeroen/expect

VAR=$(expect "
spawn /usr/bin/cadaver http://****.nl/
expect "Username:"
send "************\n"
expect "Password:"
send "************\n"
expect "dav:"
send "cd DIR/test\n"
expect "dav:"
send "lcd /home/jeroen/Desktop/mijnwerk\n"
expect "dav:"
send "mput *\n"
expect "dav:"
send "quit\n"
")

Iff anyone can help please, I'm running out of ideas.
Regards,
Jeroen

The whiz-bang line is often only allowed one argument. You seem to have missed the usage. Suppose I have a bit of sed with many uses. Rather that a ksh script calling sed explicitly, I can put the sed commands in a file with a '#!/usr/bin/sed -f' line and make it directly exec() capable. See man execvp. For command line script names, ksh, sh, bash do not need -f, but sed, awk and such do.