LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2003, 04:28 AM   #1
coolest
LQ Newbie
 
Registered: Jul 2003
Distribution: RedHat, FreeBSD
Posts: 20

Rep: Reputation: 0
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)
 
Old 07-29-2003, 12:22 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What are the permissions on that file?
ls -la /home/ryan/parsedlogs

Who are you running the script as?
 
Old 07-29-2003, 10:24 PM   #3
coolest
LQ Newbie
 
Registered: Jul 2003
Distribution: RedHat, FreeBSD
Posts: 20

Original Poster
Rep: Reputation: 0
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
 
Old 07-29-2003, 10:28 PM   #4
coolest
LQ Newbie
 
Registered: Jul 2003
Distribution: RedHat, FreeBSD
Posts: 20

Original Poster
Rep: Reputation: 0
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...
 
Old 08-16-2003, 09:58 AM   #5
richca
LQ Newbie
 
Registered: Aug 2003
Posts: 1

Rep: Reputation: 0
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...
 
Old 02-06-2008, 08:50 AM   #6
vande012
Member
 
Registered: Jul 2007
Location: Carrollton, Texas
Distribution: cent os 7 , windows 7
Posts: 83

Rep: Reputation: 15
Hmm Reponse

Just wondering if anyone has gotton rid of cwdir error ? Im receiving this when trying to transfer a file?
 
Old 03-25-2008, 02:33 PM   #7
sgotti
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
Smile

Quote:
Originally Posted by vande012 View Post
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.
 
Old 02-16-2009, 03:59 PM   #8
ruchijain15
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
putty display loops on listing directories with many files, through expect script vineet.k Linux - General 5 03-13-2007 09:44 AM
telnet server not reliable for expect script powah Linux - Software 0 11-16-2005 11:07 AM
cron job for expect script ruchitadesai Programming 9 05-27-2005 04:34 AM
trying to execute an expect script in .bashrc smaudlin Red Hat 2 01-02-2005 01:34 AM
BAD SU- from a cronned expect script ganninu Linux - General 1 07-18-2004 10:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration