cancel
Showing results for 
Search instead for 
Did you mean: 

Shell Script for the deletion of the file in FTP Protocol

former_member190358
Participant
0 Kudos

Hello ,

For some reason , I have to delete file from R/3 Application server and so i am using a shells script to do that.

Its a file to file  scenario and sender is FTP protocol.

The code is as follows.

logDir= /interface/scripts

logFile=deleteMATMASTFiles.log

host="pand0114.pan.eu"

open ${host}

cd /interface/tes

currDate=`date`

a="makt_EN_material_descr"

rm $a

and the command in the channel is :

The log shows that it executes the OS Command , but the file does not get deleted.

Can someone help me here !!

Regards,

Ravi

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi Ravi,

Use the method described by Michal in one of his blogs, to catch the results of shell script commands into some log file. See more details here:

Michal's examples are related to Windows platform, but same can be applied to Unix as well.

Regards,

Greg

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ravi,

I think you want to delete the file after pulling the file by sender comunication channel.

if this the case then you don't have to use any shellscript. You can set "Processing Mode" to "DELETE" in sender communication channel. This option is in processing tab.

Please correct me if I have misunderstood your requirement.

Regards,

Nayan

Former Member
0 Kudos

Hi,

It seems it don't have access to delete file , please check the access. try to run directly the shell on FTP to verify.

Also ist the file "makt_EN_material_descr" is without extension?

Regards

Lucho

former_member190358
Participant
0 Kudos

Yes,  the file is without extension.

Also, please let me know how to run the shell on FTP ?

Regards,

Ravi

Former Member
0 Kudos

Hi.

Pls check this link for more detail

http://www.thegeekstuff.com/2010/06/ftp-sftp-tutorial/

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I would recommend two things. Use delete command for single file deletion or mdelete command for multiple files.  Your FTP user should have permission to execute this function on the remote machine. For ftp commands please see this link

http://www.ftp-commands.com/file-transfer-protocol/delete+remote-file/?q=delete+remote-file

former_member190358
Participant
0 Kudos

Hi Luis,

In the code we have given a  log to generate .

The log files executes all the commands till the end, but the file does not get deleted from the folder.

Could you please check the code and let us know whats wrong :

logDir= /interface/scripts

logFile=deleteMATMASTFiles.log

echo "Entered script" >> $logDir/$logFile

host="pand0114.pan.eu"

open ${host}

cd /interface/tes

currDate=`date`

a="makt_EN_material_descr"

rm $a

echo "$currDate - SUCCESS-File is deleted" >> $logDir/$logFile

former_member190358
Participant
0 Kudos

Hello Baskar,

In the code we have given a  log to generate .

The log files executes all the commands till the end, but the file does not get deleted from the folder.

Could you please check the code and let us know whats wrong :

logDir= /interface/scripts

logFile=deleteMATMASTFiles.log

echo "Entered script" >> $logDir/$logFile

host="pand0114.pan.eu"

open ${host}

cd /interface/tes

currDate=`date`

a="makt_EN_material_descr"

rm $a

echo "$currDate - SUCCESS-File is deleted" >> $logDir/$logFile

baskar_gopalakrishnan2
Active Contributor
0 Kudos

The script code looks good. Check with Basis or Unix admin about file permission that requires deletion. The file permission may not be sufficient for deleting. Just for test purpose give commnad before you run the script.

chmod 777 makt_EN_material_descr

Also ask unix admin that is this FTP user requires permission to delete the file.

former_member190358
Participant
0 Kudos

Hello Baskar ,

As mentioned in your last few replies, i tried everything by checking the permission of the file with Basis and also by delete command .

The permission is full ( 777 ) and even the log file gets generated till the end .

But the file still exists on the folder. and its still not deleted.

When i try to ftp R/3 remotely from PI , then the files in the folder are not displayed. However, if i try to run the script from the machine on which  my  PI server is , then i am able to list the  files and delete the files as well.

Not sure, if i am able to login remotely and access the file.

Regards,

Ravi

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>When i try to ftp R/3 remotely from PI , then the files in the folder are not displayed

This shows that your ftp user login does not have access to view or delete those files in that directory. Thats the reason you are not able to perform delete operation.  Please check with system admin and provide this information.  They will provide full access for the user to take control on the directory.  This is not file permission.