Results 1 to 7 of 7
Greetings,
Currently, I have a process that runs three (3) times a day on our Linux server to fetch files from our Windows FTP server. Once it finds a text ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-01-2006 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 8
RHAS 2.1 File/Directory Permission Dilema - Help!
Greetings,
Currently, I have a process that runs three (3) times a day on our Linux server to fetch files from our Windows FTP server. Once it finds a text file, grabs it and move into a folder and the permission (chmod 666) to r,w,e to the file so that the file can be processed by a regular Linux user.
The script runs great, but times to times, the script does not change the permission and the processing would not be able to proceed.
Of course, as for root, I can run the process without any problems and I am not about to hand over the root password to this user. Is there a way for me to set this user up as sudo user or give him enough priv to do his work? Any advice how I could fix this problem??
Please help!!
Thank you in advance.
Jorge
- 12-01-2006 #2
Yep, make sure the file is ftp'd into a seperate directory, and fix the group permissions of the directory. You need to make sure all files in that directory get the group of the directory, you do this with the sticky bit for group permissions, i.e. 'chmod g+S <directory_name>', and set the group to 'users' with 'chgrp users <directory_name>'. Just make sure the users are listed in the 'users' group in /etc/groups.
Linux user #126863 - see http://linuxcounter.net/
- 12-01-2006 #3Just Joined!
- Join Date
- Dec 2006
- Posts
- 8
Roxoff - I am new the the Linux world. Would you be kind enough to show me the steps and the syntax? Currently, I do have the file transfer down to a folder called "ftpin". Once the file permission changed, it gets moved over to a known production folder for processing.
I think I got the concept, but not sure to to tweak the group permission as you've mentioned it.
Thank you for your time.
Jorge
Originally Posted by Roxoff
- 12-04-2006 #4
Ahhh. Right. The stuff I put in the single quotes is the right syntax... But to clarify, I'll do it with examples.
Firstly, lets assume that your ftp'd files land in /var/ftp-in, they probably dont, but it'll be an easy reference, and you can substitute the correct path and directory name in these examples. I'll also use the username 'bob', but you must again substitute the right username from your system.
Firstly, edit /etc/groups as root, do this from a command console in X:
Scroll down the file until you reach a line that looks like this:Code:cd /etc gedit group
Add 'bob' to the end of the line - dont forget the comma if there are already users in this list. All your local users shoul be listed here, btw., but you have to add them manually. In our example, we make the line look like this:Code:users:x:100:fred,bill,eric
and save the file again.Code:users:x:100:fred,bill,eric,bob
Next, we should fix the permissions on the directory where the files arrive; again at the same command prompt as root:
to get to the directory, then fix it's group with:Code:cd /var
and nail the group to any files that are written to that directory with:Code:chgrp -R users ftp-in
That should just about take care of the permissions. To make life easy for 'bob' you might want to add a symbolic link from their home directory out to the ftp-in directory:Code:chmod g+S ftp-in
You might find that, if bob is logged in while you do this, that they have to log out and in again to get the 'users' group permissions.Code:cd /home/bob ln -s /var/ftp-in ftp-in
Linux user #126863 - see http://linuxcounter.net/
- 02-12-2007 #5Just Joined!
- Join Date
- Dec 2006
- Posts
- 8
Roxoff - I will need your help on file permission again and I hope you don't mind. I really can use your help. I will cut & paste the ftp batch job that I'm currently running on the Linux server at every 15 minutes.
Here we go:
#!/bin/sh
HOST='10.0.0.1'
USER='ftpprocess'
PASSWD='ftpinfile'
DATE=`date +%m%d`
FILE='*txt'
FILE1='*TXT'
log=/tmp/ftpin_111.log
test=/tmp/getfile.test
cd /ftpin/vendorA
dat=`date`
echo $dat >> $log
ftp -n -i $HOST >> $log 2>> $log <<END_fgSCRIPT
quote USER $USER
quote PASS $PASSWD
cd ..
asci
cd vendorA
cd IN
mget $FILE 2>>$log
mdelete $FILE
quit
END_fgSCRIPT
ls /ftpin/vendorA/*.txt > $test 2>>/tmp/log
numline=`cat $test|wc -l`
if [ "$numline" -gt 0 ]; then
if [ "$numline" -gt 0 ]; then
echo "Following files have been pulled from ftp server">>$log
cat $test>>$log
chmod 666 *.txt 2>>$log
cp /ftpin/vendorA/*txt /u10/prod/live/ 2>> $log
echo "Rename files;" >> $log
/tmp/lbin/ren 's/\.txt$/.old/'>>$log 2>> $log
cd /ftpin/vendorA
ftp -n -i $HOST >> $log 2>> $log <<END_fgSCRIPT
quote USER $USER
quote PASS $PASSWD
cd ..
cd vendorA
cd IN
mput *.old
quit
END_fgSCRIPT
rm -f *.old
fi
ftp -n -i $HOST >> $log 2>> $log <<END_fgSCRIPT
quote USER $USER
quote PASS $PASSWD
cd ..
cd vendorA
cd IN
mget $FILE1 2>>$log
mdelete $FILE1
quit
END_fgSCRIPT
ls /ftpin/121mktg/*.TXT > $test 2>>/tmp/log
numline=`cat $test|wc -l`
if [ "$numline" -gt 0 ]; then
echo " Following files have been pulled from ftp server">>$log
cat $test>>$log
chmod 666 *.TXT 2>>$log
cp /ftpin/vendorA/*TXT /u10/prod/live/ 2>> $log
echo "Rename files;" >> $log
/tmp/lbin/ren 's/\.TXT$/.old/'>> $log 2>> $log
cd /ftpin/vendorA
ftp -n -i $HOST >> $log 2>> $log <<END_fgSCRIPT
quote USER $USER
quote PASS $PASSWD
cd ..
cd vendorA
cd IN
mput *.old
quit
END_fgSCRIPT
rm -f *.old
fi
exit 0
- 02-13-2007 #6
Hmmm, scripting isn't really my strong point. I would find it a lot easier to help you if you mentioned what it was that was actually going wrong.
Linux user #126863 - see http://linuxcounter.net/
- 02-13-2007 #7Just Joined!
- Join Date
- Dec 2006
- Posts
- 8
I am not a script writer myself either. But I tried and it been working for sometime now but once in awhile I would hit a bump on the road with the permission.
The purpose of this script was to bring down a file from a Windows FTP server to the Linux server. I need to chmod to rw, rw, rw (666) for the Linux server to process the file. Occasionally, the permission doesn't get reset to 666 and the process would error out.


Reply With Quote
