• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 814
  • Last Modified:

How to change file permissions in Unix shell script

Recently a unix shell script we have been using for some time stopped ftp'ing a file usnig .netrc  info to login to the ftp site.

The login information hasn't changed and the only way I am able to manually ftp the file to the site is if i change the file permissions to the .zip file the script creates.  I was thinking of adding this line to the entire shell script to have it do this form me but need help.

I have attached the lines of code in the script where the file is encrypted with pgp right before it is ftp'd.  Could someone tell me what line i could add to ensure the permissions allow for the file to be ftp'd?
export PGPPATH
export PATH
pgp +force -e -o $FILENAME.zip.pgp $FILENAME.zip data_center

Open in new window

1 Solution
It denpands on what type of users you allow them to do ftp.
If you allow ALL users to do it, you can add:
chmod a+r $FILENAME.zip
the user in the same group to FTP the file (eg $FILENAME.zip ) :
chmod g+r $FILENAME.zip
just put the statement after the file is created.
man chmod
to learn more details.
Just as said by yuzh if you want all users, groups and others to ftp the file then:

chmod 444 $FILENAME.zip

If you want group member of the file to read it and others members deny any access use this:
chmod 740 $FILENAME.zip
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now