Changing file Permission through shell script by Ftp process
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
Changing file Permission through shell script by Ftp process
Hi,
Currently i am Using A shell script to ftp to a Nt Server from where i am getting the files & after loading i am Archieving that file to a diffrent folder
on the same Nt server & then Again using a shell script to delete the file from the original location.
Now the problem with me is that i am manually making the file as read only after Archieving that, i want to implement this using shell script too.
is their any way i can implement that in shell script ,chmod command i ve already tried but that dont wotk On ftp prompt any other way to make file as read only.
Thanks In Advance
Currently i am Using A shell script to ftp to a Nt Server from where i am getting the files & after loading i am Archieving that file to a diffrent folder
on the same Nt server & then Again using a shell script to delete the file from the original location.
Now the problem with me is that i am manually making the file as read only after Archieving that, i want to implement this using shell script too.
is their any way i can implement that in shell script ,chmod command i ve already tried but that dont wotk On ftp prompt any other way to make file as read only.
Thanks In Advance
Doesn't the file automatically receive the remote file user's login umask? That might be changed to limit access.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
chulett wrote:As long as the remote server allows it, there are the 'Telnet before' and 'Telnet after' commands available inside the FTP stage. Setup the 'after' session to log in and issue the chmod command.
Hi craig can u tell me exactly wat should i specify in that option to change the permission or should i directly fire that chmod command in telnet after session option.
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
But the problem here is when i try to telnet that server from command prompt its says Could not open a connection to host: Connect failed.chulett wrote:The same series of steps you would have to do if you were telnet'ing into the box after the ftp and changing the permissions yourself.
Might be server was not configured for recieving incoming telnet sessions.
.Is their a way of doing it through some script.
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
Hi ketfos,
Archieving i am doin just by Ftp>ftp stage so its just creating a similar copy to another folder then after completing this job i am deleting the file from original location by using shell script ,in that i am using delete command to delete the file [#!/bin/sh
HOST=$1
USER=$2
PASSWD=$3
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
delete /ftp_mxg2000/$4
quit
END_SCRIPT
exit 0][/code]
Archieving i am doin just by Ftp>ftp stage so its just creating a similar copy to another folder then after completing this job i am deleting the file from original location by using shell script ,in that i am using delete command to delete the file [#!/bin/sh
HOST=$1
USER=$2
PASSWD=$3
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
delete /ftp_mxg2000/$4
quit
END_SCRIPT
exit 0][/code]
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
See the exact problem of mine in the beginning i know i can use command stage for shell script my problem is that how can i change file permission if i archieve a file to some other foldercmmurari wrote:you can use command stage in server jobs
i want to make it read only after successful transfer.
can any one give better solution]
Thanks
Hi Khanparwaz,
Since you ahve mentioned that you want to do change file permission only after successful transfer so -
1. Redirect the output of ftp to file say ftplogfile by using a redirection (>) in your orignal ftp script.
2. Second step is you need to check for successful file transfer.
After quit command in the script,
you can call another shell script. In this script you should check as
ftp_return_code=`grep -i "226 Transfer complete." /ftplogfile | wc -l`
if [[ $ftp_return_code -ne 1 ]]
(note - assumed only 1 file is being ftp'ed)
then echo " FILE CREATION FAILED"
else
chmod command
fi
Since you ahve mentioned that you want to do change file permission only after successful transfer so -
1. Redirect the output of ftp to file say ftplogfile by using a redirection (>) in your orignal ftp script.
2. Second step is you need to check for successful file transfer.
After quit command in the script,
you can call another shell script. In this script you should check as
ftp_return_code=`grep -i "226 Transfer complete." /ftplogfile | wc -l`
if [[ $ftp_return_code -ne 1 ]]
(note - assumed only 1 file is being ftp'ed)
then echo " FILE CREATION FAILED"
else
chmod command
fi
I have seen some ftp that suppport umask for the target files.
But most ftp implementations support some kind of local shell capability, so you can say something like this in your ftp script after the files have been recieved.
....
get $filename
....
! chmod 111 $filename
....
Check the documentation for the ftp on your host.
Carter
But most ftp implementations support some kind of local shell capability, so you can say something like this in your ftp script after the files have been recieved.
....
get $filename
....
! chmod 111 $filename
....
Check the documentation for the ftp on your host.
Carter
-
- Participant
- Posts: 60
- Joined: Tue Jul 12, 2005 3:34 am
clshore wrote:I have seen some ftp that suppport umask for the target files.
But most ftp implementations support some kind of local shell capability, so you can say something like this in your ftp script after the files have been recieved.
....
get $filename
....
! chmod 111 $filename
....
Check the documentation for the ftp on your host.
Carter
Hi Carter Thanks for reply
But still i am in problem my ftp server is on NT box & ds server is unix
so by command ! chmod it takes me back to unix prompt again & as error i get can't access file one more thing i want to tell you that i can not telnet
the ftp server too & with these conditions i have to change file permissions.