change the mode of the file after FTP

Hi
I am FTPing a file to a remote server from my local server. But after I FTP it the permissions are not in executable option, I need to change the permissions of the FTPed file how can i do that. Below is my script

LOCALDIR=/batch/ediprocess
LOCAL_BACKUP_DIR/batch/ediprocessBackUp
FTPCMDFILE=//batch/cmdftp.cmd
APP_SCRIPT_DIR=/batch
FTPLOGFILE=/batch/ftpTest.log
REMOTESERVER=test.appl.com
REMOTE_DIR=/batch/ftpTest
REMOTE_USER=hello
REMOTE_PWD=abcd
chmod 777 $LOCALDIR/*.csv
echo "user $REMOTE_USER $REMOTE_PWD"   > $FTPCMDFILE
echo "cd $REMOTE_DIR"             >> $FTPCMDFILE
echo  "lcd $LOCALDIR"              >> $FTPCMDFILE
echo "chmod 777 $LOCALDIR/*.csv"   >> $FTPCMDFILE
echo "bin"                          >> $FTPCMDFILE
echo "mput *.csv"               >> $FTPCMDFILE
echo "lcd $APP_SCRIPT_DIR"            >> $FTPCMDFILE
echo "chmod 777 $REMOTE_DIR/*.csv"  >> $FTPCMDFILE
echo "bye"                            >> $FTPCMDFILE
ftp -niv  $REMOTESERVER < $FTPCMDFILE > $FTPLOGFILE
logon_succ=`grep -ci "Goodbye" $FTPLOGFILE`
if [ $logon_succ -eq 0 ]
then
  echo "Ftp to Vendor-000009 Failed " 
else
   
  echo "Ftp to Vendor-000009 successfull"
  #echo "File Name :"$Out_FileName >> $FTP_MAIL
  mv $LOCALDIR/*.csv $LOCAL_BACKUP_DIR
fi
        I tried changing the permission of the remote file but i am not able to do it. 

regards
Prashanth

Wildcards are not allowed in the ftp implementation of chmod. The ftp environment is not shell but does have some similar commands.

Maybe consider restructuring the script to ftp the files one-by one (using put not mput) you should then be able to chmod the individual file.
This is a general statement because we don't know what Shell you have, what Operating Systems are involved or or what ftp software you are using. Not all ftp versions implement chmod.
If you can type it at the command line you can script it.

Btw. chmod 777 is not the normal permissions for a data file. The loosest permissions would be 666 .
If you have control over the comms configuration unix "rcp" might be more suitable.

Hi
i have tried using this command in the FTP
site chmod -R 777 /batch/ftpTest but it throws the following error
550 SITE CHMOD command failed. Does this mean the user I am trying to use does not have the required permissions?

I have also tried putting each file one after another (using put rather than mput).

I have got this command when searching in forums in this site.

regards
Prashanth

Hello Chandra,
From my experience, you will not be able to change permissions of remote file using ftp/sftp. You can do below mentioned approach.

  1. Configure SSH public key authentication b/w these 2 servers(There are several posts for this)

  2. Once you see SSH public key authentication working, you can use ssh to change the permission.

-Nithin.

It would still help to know what software you have.

This command looks unlikely to me:

Please try the very basic form of the command. Many ftp commands do not accept full pathnames or command switches. The chmod will only ever work if the account on the remote server has permissions to issue a chmod on the directory and if local ftpd policy allows the function. The permissions on the directory are important too. The "rhelp" (remote help) and similarly "rhelp site" at your ftp prompt should tell you whether the chmod command is implemented.

cd /batch
dir ftpTest
put ftpTest
dir ftpTest
chmod 777 ftpTest
dir ftpTest

If local rules allow there are much better methods than ftp to transfer files between unix servers.