Retain file permissions when saving .sh file from internet [OS X]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Retain file permissions when saving .sh file from internet [OS X]
# 1  
Old 12-11-2008
Retain file permissions when saving .sh file from internet [OS X]

Hello.
I have written a bash script that I am sharing with an OS X community I am a member of. The purpose of the script is to execute a series of commands for members without them having to get involved with Terminal, as it can be daunting for those with no experience of it at all. I have renamed the file from .sh to .command, as this allows you to execute it by double-clicking the file in the OS X file manager.
The file saves itself from my script editor [Smultron] with read and write permission only, and not executable permission; I use chmod 755 {file} to give myself execute permission, and then upload the file using ftp. Connecting to my server with ftp I then find that the file permissions have changed back to read/write, so I again use chmod in the ftp shell and change the permissions again. I thought this would have prevented the following problem, but I guess not-
When I, or anyone else, saves the file from the public domain folder I have hosted it in, the permissions are back to not being executable. Of course, this can be fixed with chmod +x, but that rather defeats the purpose of the script if they have to get involved with Terminal at all.

Could anyone please suggest a way to resolve this issue, ie how can I get the file to have persistent executable permission for all? It's driving me nuts at this stage.. I've put quite a lot of effort into the script.

Thanks
# 2  
Old 12-11-2008
Not likely with ftp. Even if your receiving system had a umask of 0000, the file would not have execute permission.

You could try to use rsync over ssh. rsync has an option to preserve file permissions (-p).
# 3  
Old 12-11-2008
They're not downloading it by ftp though, they're just using Save Link As in Firefox or whatever.
# 4  
Old 12-11-2008
After you change the perms, try tar/gzipping the file.. Then they could download it, unzip and it may have execute still...Not tested, but should work.
# 5  
Old 12-11-2008
Quote:
Originally Posted by jimbalaya
After you change the perms, try tar/gzipping the file.. Then they could download it, unzip and it may have execute still...Not tested, but should work.
Delightful. That works perfectly. Not ideal, but will do for now Smilie thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

[Solved] Removing duplicates from the file and saving as new file

Dear All I have 200 data files and each files has many duplicates. I am looking for the automated awk script such that it checks and removes the duplicates from the each file and saving them as new files for all 200 files in the respective folder. For example my data looks like this.. ... (12 Replies)
Discussion started by: bala06
12 Replies

2. UNIX for Dummies Questions & Answers

cat to a file but retain header

Hi, Is there a way to write to a txt file each day but retain the header on the file? I'm cat'ing 5 files into one .txt file each day but I want the new data to be written after the first 2 lines which are: Progname Size Date Owner ---------------------------- Basically I want my new... (4 Replies)
Discussion started by: Grueben
4 Replies

3. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

4. Shell Programming and Scripting

How to retain backslash in a line while reading a data file?

Hello Firends I have a file that contains data within single quotes, which has meaning of its own. When I am trying to parse through the file for a different functionality I noticed that I was loosing the backslash when occurrences in the file look like ('\0'). I would want to retain the... (3 Replies)
Discussion started by: easwam
3 Replies

5. Shell Programming and Scripting

retain last 1000 line in a file

I have large file with around 100k+ lines. I wanted to retain only the last 100 lines in that file. One way i thought was using tail -1000 filename > filename1 mv filename1 filename But there should be a better solution.. Is there a way I can use sed or any such command to change the... (9 Replies)
Discussion started by: nss280
9 Replies

6. Shell Programming and Scripting

Retain File Timestamp

There are directories of files that I have to run the dos2ux command on to get ride of the carriage return characters. Easy enough, but I have to retain the original timestamps on the files. I am thinking that I am going to have to strip off the timestamp for each file and convert it to unix time... (3 Replies)
Discussion started by: scotbuff
3 Replies

7. UNIX for Advanced & Expert Users

Retain Only specific number of file in Directory

I want to retain specific number of backup files in a directory.for example i want to retain only two latest backup file in backup directory. If number of backup files is greater than this policy that it will delete oldest file.Please Tell me whether this is possible or not. (2 Replies)
Discussion started by: ranvijaidba
2 Replies

8. UNIX for Dummies Questions & Answers

How to retain the header information of a file

Hi, I am using Bash shell to create some data and these data would be piped out to a file, let say output.txt. This output.txt I would like to add some extra header information such as comments, descriptions and general information on the text. I would like to know how could I maintain... (0 Replies)
Discussion started by: ahjiefreak
0 Replies

9. UNIX for Advanced & Expert Users

How to retain file permissions during FTP on Solaris 5.9 ?

Hi All, I am trying to ftp a file : -rw-rw-rw- 1 oraclepbdw dba filename.txt from Machine A ( where umask is 022) to Machine B (umask 022) but the file changes to -rw-rw-r-- 1 ftpamle3 ftaml filename.txt Dur some constraints the group of the users on either side... (3 Replies)
Discussion started by: gauravsachan
3 Replies

10. Shell Programming and Scripting

parse an arpwatch file and retain most recent mac

Hi, I'm working on a little script, for first I transformed epoch (unix date in seconds) in a human readable date in this way cat arp.dat | sort -k 3 | gawk '{ print strftime("%d:%m:%Y:%H:%M", $3),$1,$2}' the result is 06:03:2006:10:01 0:a:e4:c0:b5:6d 192.168.1.3 06:03:2006:12:15... (8 Replies)
Discussion started by: CM64
8 Replies
Login or Register to Ask a Question