Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh script help

Status
Not open for further replies.

7280

MIS
Apr 29, 2003
331
IT
Hi,
i have the following script:

SET_ENV ()
{
DESTDIR=/home/tarek/my_documents
DATE=`date +'%m%d`_????
LOCALDIR=/home/oracle/test/$DATE/files
LOGFILE=$LOCALDIR/script_ftp.log
FILE=pippo*
}

FTP_FILES ()
{
echo "####################"
echo "STARTING FTP SESSION"
echo "####################"
ftp -n ip <<eof
user $1 $2
ascii
prompt
lcd $LOCALDIR
cd $DESTDIR
put $FILE
bye
eof
EXITSTAT=$?
echo &quot;Exit status from FTP is $EXITSTAT&quot;
if [ $EXISTAT -eq 0 ]
then
echo &quot;FTP Was OK&quot;
else
echo &quot;ERROR: unknown-error after <FTP_FILES> for file <$FILE> &quot;
exit -2
fi
}

MAIN ()
{
SET_ENV
exec > $LOGFILE 2>&1
FTP_FILES user password
}

MAIN

I have an error while trying to create the $LOGFILE:
A file or directory in the path name does not exist.
./script_files[3]: /home/oracle/test/0919_????/files/script_ftp.log: 0403-005 Cannot create the specified file.

Any idea?
And then how can i test the existatus of the ftp?
If the ftp is ok or it has an error $? is always 0.
Tarek
 
The exit status of FTP is always 0 even when it fails.

bash-2.03$ ftp ;echo $?
ftp: connect: Connection refused
ftp> bye
0


Turn on logging for it and check the FTP return codes like 221 or whatever.



Have you check the permissions on /home/oracle ?
 
I have permissions to write that directory, but i'm unable to do it!

What do you mean with:
&quot;urn on logging for it and check the FTP return codes like 221 or whatever.&quot;
How can i turn loggin on?
 
Turn on logging, if its the server by editing /etc/inetd.conf


Change the

ftp stream tcp nowait.80 root /usr/sbin/tcpd in.ftpd

to

ftp stream tcp nowait.80 root /usr/sbin/tcpd in.ftpd -d 2

Then pkill -HUP inetd

And add a logging line into syslog.conf file.
then pkill -HUP syslogd

Debug stuff should start turning up in /var/adm/messages if you have added

daemon.debug /var/adm/messages to syslog.conf



 
Also run the script with -v specified in the shell bit and it will show you whats happening.

 
The question mark is a shell meta-character. It should not ordinarily be used in filenames and I suspect that's the problem here. Try using a different value in its place. If you absolutely must use &quot;?&quot;, you'll need to quote the name in any context that uses it.
 
could have escaped them out

mkdir HairyArse/???

would make a directory called

HairyArse???

 
Nah, don't worry, I'm not one to split hairs, no matter what provenance they may have!
 
I would have thought especially their provenance would encourage you not to [split hairs].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top