Skip to content

Tag: linux

Protect PHP source code

due to bad internet bandwidth in my country, the client wishes for me to install my PHP/MySQL application on his Windows server or a Linux server. What is the best way to protect the source code? Or the folder where the PHP source code resides. The client should be able to use the rest of the server freely. T…

How to cat <> a file containing code?

I want to print code into a file using cat <<EOF >>: but when I check the file output, I get this: I tried putting single quotes but the output also carries the single quotes with it. How can I avoid this issue? Answer You only need a minimal change; single-quote the here-document delimiter after …

While loop not equal command not found

I am trying to perform a simple while loop comparing a variable to a string. It fails to load with the error on this line. Error states [: missing `]’ and : command not found. My while loop looks like; Answer There are a couple of errors: See that variable declaration do need to be like var=value. Other…

Check if a directory exists and is accessible

I want to check if a directory exists and it has access rights; if it does, then perform the tasks. This is the code I wrote, which might not have proper syntax. Can you help me to correct it? I believe this can also be written like this. How can we write this more efficiently? Answer The best way to

Alternative to writing many files. MongoDB?

I have a Perl script that produces ~10000 files in the 1kB – 10kB size area, which is not optimal for performance, so I though about using MongoDB instead of writing the many files. I need to run the script on my laptops Linux and OSX. Question Would MongoDB be overkill? Or are there something more suit…

scp a folder to a remote system keeping the directory layout

I have a large directory tree with hundreds of nested sub-folders. I need to copy only 4 folders and their contents to a remote system, but I need to destination folder structure to be kept the same. E.G. I want to copy ./test/sub1/subsub1/* to a target such as user@system:~/test/sub1/subsub1/* but I do not w…