[Gambas-user] Problem with file access

Gianluigi gradobag at gradobag.it
Thu May 18 11:15:49 CEST 2023


Il 18/05/23 00:37, Bruce Steers ha scritto:
>
> On Wed, 17 May 2023, 23:10 Dag JNJ, <gambas at cd-bahia.com> wrote:
>
>     Hi all,
>     suddenly I have got access denied handling files. In a terminal
>     window everything works fine, but from within Gambas I get access
>     denied. I have
>     /If Exist(dPDF) Then Kill dPDF -> IDE stopps  with access denied
>     message
>     /dPDF is the filename of a pdf-file. It worked fine until the
>     afternoon today. I tried chmod -r +rw . and chown -r dagj . from
>     the current Application.Path, but that changed nothing, Then I tried
>     /Shell "pdftotext  -layout " & ch3 & dPDF & ch3 & " " & fntxt Wait
>     /fntxt is the filename of the output textfile. Result:
>     /I/O Error: Couldn't open file 'data/AMZ/2020/Amazon.es - Pedido
>     406-4690641-7441902.pdf': No such file or directory.
>     /
>     But when//I try this in a terminal window (Print instead of Shell
>     and copy the result from the Gambas console then paste this into
>     the terminal window), it works,
>     /pdftotext  -layout "data/AMZ/2020/Amazon.es - Pedido
>     406-4690641-7441902.pdf"
>     "data/AMZ/BEARBEITET/TXT/406-4690641-7441902.txt"/
>
>     I am hanging a little  now, and appreciate any help.
>     Regards,
>     Dag
>
>
> Where is "data" ?
>
> If it's a disk then that code is okay.
>
> If it's a Dir in the project folder then it is wrong.
>
> To use a shell command you will need to save the file to /tmp or 
> somewhere and have it output it's text there too.
>
> Or use absolute paths to work in project dir with
> Application.Path &/ dPDF
>
>
> BruceS
>
>
>     ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
> ----[http://gambaswiki.org/wiki/doc/netiquette  ]----

Hi Dag,

they seem correct suggestions check the paths well, I added in my home a 
TEST folder and running this code, everything works fine without errors:

Public Sub Main()

   ' gian at gian:~$ pdftotext -layout dPDF.pdf TEST/dPDFbyShell.txt
   Try Shell "pdftotext -layout dPDF.pdf TEST/dPDF.txt" Wait
   ' Try Exec ["pdftotext", "-layout", "dPDF.pdf", "TEST/dPDF-2.txt"] Wait
   If Error Then Print Error.Text

End

I attach image of the TEST folder

Regards

Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230518/be62c6fb/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dag-test.png
Type: image/png
Size: 27660 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230518/be62c6fb/attachment-0001.png>


More information about the User mailing list