LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Expect Script (https://www.linuxquestions.org/questions/programming-9/expect-script-76858/)

coolest 07-29-2003 04:28 AM

Expect Script
 
#!/usr/local/bin/expect
set User "updates"
set Password "updates"
set Prompt "ftp>"
set Host "ftp.freedomain.com"
set Yes "prompt"
set Local "/home/ryan/parsedlogs/"
#set Yehey "mput yehey*"
################################################# Connect to FTP
spawn "/home/ryan/parsedlogs"
spawn ftp $Host
################################################# Username
expect "Name (ftp.freedomain.com:ryan):"
send "$User\n"
################################################# Password
expect "Password:"
send "$Password\n"
################################################# Enter Command Option of FTP
#expect "$Prompt"
#send "passive\n"
expect "$Prompt"
send "$Yes\n"
expect "$Prompt"
send "hash\n"
################################################# Upload yeheylogs files
expect "$Prompt\n"
send "mput $Local*.*\r"
expect "$Prompt"
send "ls -al\n"
expect "$Prompt\n"
send "bye\n"


and when i run the script it says

spawn /home/ryan/parsedlogs
couldn't execute "/home/ryan/parsedlogs": permission denied
while executing
"spawn "/home/ryan/parsedlogs""
(file "/home/ryan/scripts/ftptest.exp" line 10)

david_ross 07-29-2003 12:22 PM

What are the permissions on that file?
ls -la /home/ryan/parsedlogs

Who are you running the script as?

coolest 07-29-2003 10:24 PM

Hi David_Ross thanks for reply

the permission is

drwxr-xr-x 2 root root 4096 Jul 28 09:57 parsedlogs

The script is running as a root I think :( I'm not sure how do i set it to run as a root always... I'm kinda new in scripting

Thanks

coolest 07-29-2003 10:28 PM

Hi David_Ross,

When i comment the line 9 #spawn "/home/ryan/parsedlogs" it run but the says:

ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> mput /home/ryan/parsedlogs/*.*
local: /home/ryan/parsedlogs/yeheylogs.2003071819171058527061 remote: /home/ryan/parsedlogs/yeheylogs.2003071819171058527061
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072419031059044582 remote: /home/ryan/parsedlogs/yeheylogs.2003072419031059044582
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072519541059134083 remote: /home/ryan/parsedlogs/yeheylogs.2003072519541059134083
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072519591059134350 remote: /home/ryan/parsedlogs/yeheylogs.2003072519591059134350
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072613591059199175 remote: /home/ryan/parsedlogs/yeheylogs.2003072613591059199175
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072617141059210868 remote: /home/ryan/parsedlogs/yeheylogs.2003072617141059210868
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072617531059213223 remote: /home/ryan/parsedlogs/yeheylogs.2003072617531059213223
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072618361059215790 remote: /home/ryan/parsedlogs/yeheylogs.2003072618361059215790
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072817571059386223 remote: /home/ryan/parsedlogs/yeheylogs.2003072817571059386223
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.

I dont think there's no file, the script cant upload it... I don't Get it...

richca 08-16-2003 09:58 AM

Hi, Coolest,

I believe you forget to check if remote server has the same
path "/home/ryan/parsedlogs". If you really need that path,
you can use "send "mkdir $path" to create it, or not, you
You need add some sentences before <send "mput..." >:

send "cd $DESTINATION_PATH" #change remote working path.
expect "ftp>"
send "lcd /home/ryan/parsedlogs\" # change local working path.
expect "ftp>"
send "mput *.*\r"
expect "ftp>"

Also please don't use < expect "ftp>"> like above, because no matter failure or success result always give you ftp>.



Quote:

Originally posted by coolest
Hi David_Ross,

When i comment the line 9 #spawn "/home/ryan/parsedlogs" it run but the says:

553 Could not determine cwdir: No such file or directory.
local: /home/ryan/parsedlogs/yeheylogs.2003072817571059386223 remote: /home/ryan/parsedlogs/yeheylogs.2003072817571059386223
200 PORT command successful.
553 Could not determine cwdir: No such file or directory.

I dont think there's no file, the script cant upload it... I don't Get it...


vande012 02-06-2008 08:50 AM

Hmm Reponse
 
Just wondering if anyone has gotton rid of cwdir error ? Im receiving this when trying to transfer a file?

sgotti 03-25-2008 02:33 PM

Quote:

Originally Posted by vande012 (Post 3047975)
Just wondering if anyone has gotton rid of cwdir error ? Im receiving this when trying to transfer a file?

Hi,

cwdir error occurs when the file which you are ftpying is not found.

Do not use *.* if using 'put',and if you using mput, give 'filename.*' instead of '*.*'.

Let us know if you stil have problem in doing ftp.

ruchijain15 02-16-2009 03:59 PM

Getting Could not determine cwdir: No such file or directory. error
 
Hi,

Can someone please help me. I am trying to do ftp using a script and getting error as Could not determine cwdir: No such file or directory.

The code in the script is as below:

FILE="/home/file1.txt"

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
bye
END_SCRIPT


All times are GMT -5. The time now is 10:24 AM.