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) |
What are the permissions on that file?
ls -la /home/ryan/parsedlogs Who are you running the script as? |
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 |
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... |
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:
|
Hmm Reponse
Just wondering if anyone has gotton rid of cwdir error ? Im receiving this when trying to transfer a file?
|
Quote:
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. |
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. |