[Gambas-user] Bash-Script

T Lee Davidson t.lee.davidson at gmail.com
Sat Jun 4 18:48:18 CEST 2022


On 6/4/22 12:08, T Lee Davidson wrote:
> On 6/3/22 21:40, T Lee Davidson wrote:
>> On 6/3/22 13:46, Hans Lehmann wrote:
>>> Hello.
>>>
>>> For a Gambas project I need (obviously) a special variant of the cp command in a bash script.
>>>
>>> The batch file cpwp2wo.sh is necessary to copy the folder with the generated website - described with HTML+CSS+GAMBAS 
>>> (WebPage) - into the folder where the web server looks for websites. In addition, the bash script takes care of the correct 
>>> ownership of folders and files, because the web server runs under the rights of the web user www-data as well as the 
>>> appropriate rights. But that is secondary here.
>>>
>>> In a folder ws_sample there are the three folders a, b and c as well as the batch file cpwp2wo.sh. Only all three folders are 
>>> to be copied to $HOME/public_html/cgi-bin - without the file cpwp2wo.sh. I am currently copying with this command. The batch 
>>> file is also copied.
>>>
>>> cp -r -u -v $HOME/WS/ws_sample/ $HOME/public_html/cgi-bin/
>>>
>>> Any hint will be gladly read.
>>>
>>> With kind regards
>>>
>>> Hans
>>
>> Is there a problem with having the script file in the cgi-bin directory? Security reasons perhaps?
>>
>> Could you create a dummy cpwp2wo.sh file with zero content and use the --no-clobber option? Or would that contradict the 
>> --update option?
> 
> I originally assumed that there is a specific reason why your executable script is located within your data file directories. I 
> also assumed there is a specific reason why you must issue only one copy command. But, after thinking about it, I have to 
> question those assumptions.
> 
> Can the script be located other than with your data files?
> Is there any reason you cannot simply issue three copy commands like this?
> cp -r -u -v $HOME/WS/ws_sample/a $HOME/public_html/cgi-bin/a
> cp -r -u -v $HOME/WS/ws_sample/b $HOME/public_html/cgi-bin/b
> cp -r -u -v $HOME/WS/ws_sample/c $HOME/public_html/cgi-bin/c

Another question is, does it have to be strictly a copy command? Or, can you use a `for` loop?
for d in $(find ws_sample/* -type d); do cp -ruv $d cgi-bin/; done


-- 
Lee


More information about the User mailing list