Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

piaband

macrumors newbie
Original poster
Jan 4, 2022
2
0
All,

I have an odd issue that I'm hoping someone randomly knows a solution for. I have created script shell executable files to run RSYNC commands, backing up certain files on my MacBook. I can automate these files to open in terminal and create daily backups. I created these files on a 2013 MacBook Pro many years ago, and I am trying to transfer them to my brand new M1 Pro MacBook Pro.

I have the Executable files that I transferred from my previous MacBook (2013 running Monterey). These executables work fine on the older MacBook. When I copy them to my M1 Mac, they initially work as normal, but I need to update the file pathways to reflect new folders on my new MacBook. The moment I edit/save the executable file with TextEdit, I receive a message upon trying to open the file (This file has been damaged. It is recommended that you delete this file.)

I went back to my older MacBook and I remembered running into this issue several years ago when I first created these files. TextEdit does not work to create these executable files. TextEditor (which is on my older MacBook Pro) works just fine to create these executable files. Unfortunately, TextEditor is not included with my new MacBook Pro, nor can I find anywhere to download it online. I tried a different text editing app, CotEditor, but the result is the same as TextEdit.

Anyone understand why TextEditor is different than TextEdit? Is there another app I can use or where I can download TextEditor?

Thanks,
PIA
 
For anyone else that comes across this, I had to create the file differently when using TextEdit.

1. Create a .txt file and add the rsync code.
2. "Save As" and save as filename.command (uncheck the box to default the filetype).
3. Enter terminal and run
Code:
sudo chmod u+x filename.command
This will set the proper permissions to open the file.
4. Double click the file to open in terminal.

Also, I could not edit the .command file once it was created. This would cause the same damaged file issue. To make changes, I had to edit a .txt file and save a new .command file. Then, rerun the terminal permissions code.
 
sudo is not necessary, chmod +x filename.command is enough. It makes the file executable (double-click to open in Terminal) and it leaves it open for edits with TextEdit (right-click, open with).
 
  • Like
Reactions: NoBoMac
This has been an issue for ages with TextEdit. TextEdit adds a quarantine attribute to the file. If you remove it, all is good.

Code:
% xattr foo
com.apple.TextEncoding
com.apple.lastuseddate#PS
com.apple.quarantine
% ./foo
zsh: operation not permitted: ./foo
% xattr -d com.apple.quarantine foo
% ./foo
hello world
%

If you use the "vi" command to edit text files, no such problems.
 
  • Like
Reactions: synicalx1
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.