NetBeans FTP File Permissions Fix
I’ve been trying out NetBean’s “PHP Application from Remote Server” feature this weekend. The idea is that when you save a file, it uploads that file to a remote server where it can be run.
The problem I ran into is that when NetBeans uploads that file and overwrites the old version, the permissions on the file change. I did some searching and it sounds like NetBeans doesn’t set permissions on the file, which means it just takes the server default. This doesn’t make much sense (should keep permissions of previous file) and for me it meant that the permissions were set so low that I couldn’t run the PHP scripts I was uploading.
It’s simple enough to change the permissions on those files.
chmod -R 777 /path/to/files
But you have to run this command every time you make a change. This is a royal pain when you’re making a lot of small changes (like when you’re trying to track down a bug for example).
One solution might be to try hooking into the ftp server daemon to run that command every time something is committed, but that sounded like too much work. I came up with a better solution.
Instead, I decided to just run that command in a loop. The following scripts runs infinitely (until execution is stopped) and waits 1 second, then runs the permission command.
while (true); do
sleep 1
chmod -R 777 /path/to/files
done;
If you want to be able to do anything else in the command line while this is running, it’s probably a good idea to run it in a screen.
Also, you can end the execution of this script with CTRL+C. Otherwise it will continue executing forever.
“Also, you can end the execution of this script with CTRL+C. Otherwise it will continue executing forever.”
Thanks for that tip on this… I’m not much of a sysadmin and that would have kept me worried why it wasn’t “finishing” so to speak.
Paul
Webmaster
Home Theater Hack
Oh, I’ve tried this one, and I still can’t get it running properly. As Paul said it, it keeps on executing forever. Help?Anyone?
Truly yours,
Daniel
As I understand it, checking the “Preserve Remote File Permissions” in “File->Projekt Properties->Run Configuration” will keep the file permission on the server.
Still, the first time you upload the file you need to set the permission manually though. This can be most likely be done configuring some umask property in the configuration file of the ftp server.