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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using chmod in scripts. 2

Status
Not open for further replies.

glynis

Technical User
Jan 3, 2001
17
GB
I need to change the permissions on a file that has come in from an external interface.I have tried putting chmod 666 filename in a batch file via a menu and it wont work.This needs to be done so the user doesn't have to contact me every time they need to import a file to Sunaccounts.
Can anyone help me?
 
Does the user changing the mode of the file own it? If the user does not own the file then chmod wont work unless it's the root user who's changing the mode.

Hope this helps.

- Stuart
 
Okay thats probably the case so how do I get round it?
I really don't want to be chmod-ing files every day!!!!!!
 
I've just tested the above and the file is coming in via ftp.It seems to pick up the user AIX login name at this point.
Maybe if I change the ownership to the required user I can find out whether I can change the permissions.What do you think?
 
The ftp command should give the file ownership to the ftp user copying the file to your system. By default the mode takes the value of the user's umode in their .profile or 644 I think. This is worth checking.

If you change the ftp user to the user you need to run the chmod command, then chmod on the file will work. However, be sure there are no security issues with changing the ftp user.

Another alternative you might want to check is mailing the root user when the ftp takes place, which would then in-turn trigger a script to run chmod on the file. This might be a bit complex though :).

Hope this helps.

- Stuart

"Ask a question and be thought a fool once, or keep silent and be thought a fool for life"
 
We had the same problem and got around it by making the ftp user chmod the file.
All I added in the ftp script is ;
site chmod 666 filename
after the file was transfered.
 
Tison is right, I forgot about the site command (it's not on the Solaris box I administer more often :) ). Why is it the simpliest solutions always seem to slipe our minds :) ? Thanks for the backup Tison.

This is the simpliest solution glynis, you should try it.

Regards.

- Stuart
 
When you mean site command do you mean physically typing in the word 'site' or is this meant to be an IP address?
I don't appear to have the command on my AIX O/S.
 
The 'site' command is a command you use in an ftp session just like 'put' and 'get'. It allows you to use an OS command (like chmod) in an ftp session. If you still don't get what I mean just start a regular ftp session by typing 'ftp'. You'll get the '>' prompt, then type '?' for help (list of all commands available) and you'll see the command among the list shown.

Regards.

- Stuart
 
What a Star Stuart!!
I'll test this out in the morning and let you know.
Thanks for all your help.
 
Stuart,Unfortunately I don't have site as one of the ftp commands I can use.However I have got round the problem for now by setting up a crontab job in the Unix directory which chmods the files every 5 mins.Not a perfect solution but hey it works!!!

thanks for all your help

Glynis

 
The AIX standard ftp server supports the [tt]chmod[/tt] command!

I hope it works...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top