shell() and pdftotext

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

shell() and pdftotext

Stephen Barncard via use-livecode
Hello,

I want to extract .txt from a pdf-file using Livecode 9.5 on macOS Catalina.

Therefore I installed from http://www.xpdfreader.com/
the xpdf-tools-mac-4.02
and using the Terminal with „pdftotext /Users/hillen/Desktop/inter.pdf“
I get a clean text-file inter.txt. Wonderful!

So I hopefully wrote in Livecode:
 
——————
 put "/users/hillen/Desktop/inter.pdf" into fn
 put "pdftotext " & fn into Kommando
   
if there is not a file fn then
      answer  „no SourceFile!"
      exit to top
 end if
       
get shell(quote & Kommando & quote)
   
answer it & return & the result
——————

But extracting doesn´t work and I get the answer:

/bin/sh: line 1: pdftotext /users ……pdf: No such file or directory

and the result ist 127.



Typing to Terminal „pdftotext“ I get a List with command-options.

With
get shell(„pdftotext“) with and without quotes

I get the answer „/bin/sh: line 1: pdftotext: command not found“



What is wrong? May you please help?

Richard.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: shell() and pdftotext

Stephen Barncard via use-livecode
My guess is that shell can’t find your executable.  Try using full paths.

Thanks,
Brian
On Jan 12, 2020, 2:54 PM -0500, Hillen Richard via use-livecode <[hidden email]>, wrote:

> Hello,
>
> I want to extract .txt from a pdf-file using Livecode 9.5 on macOS Catalina.
>
> Therefore I installed from http://www.xpdfreader.com/
> the xpdf-tools-mac-4.02
> and using the Terminal with „pdftotext /Users/hillen/Desktop/inter.pdf“
> I get a clean text-file inter.txt. Wonderful!
>
> So I hopefully wrote in Livecode:
>
> ——————
> put "/users/hillen/Desktop/inter.pdf" into fn
> put "pdftotext " & fn into Kommando
>
> if there is not a file fn then
> answer „no SourceFile!"
> exit to top
> end if
>
> get shell(quote & Kommando & quote)
>
> answer it & return & the result
> ——————
>
> But extracting doesn´t work and I get the answer:
>
> /bin/sh: line 1: pdftotext /users ……pdf: No such file or directory
>
> and the result ist 127.
>
>
>
> Typing to Terminal „pdftotext“ I get a List with command-options.
>
> With
> get shell(„pdftotext“) with and without quotes
>
> I get the answer „/bin/sh: line 1: pdftotext: command not found“
>
>
>
> What is wrong? May you please help?
>
> Richard.
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: shell() and pdftotext

Stephen Barncard via use-livecode
To find the full path, this may work - open Terminal and type:

     which pdftotext

and it should display the path to the copy of pdftotext that the OS runs
when you type the 'pdftotext' command.

Phil Davis


On 1/12/20 2:00 PM, Brian Milby via use-livecode wrote:

> My guess is that shell can’t find your executable.  Try using full paths.
>
> Thanks,
> Brian
> On Jan 12, 2020, 2:54 PM -0500, Hillen Richard via use-livecode <[hidden email]>, wrote:
>> Hello,
>>
>> I want to extract .txt from a pdf-file using Livecode 9.5 on macOS Catalina.
>>
>> Therefore I installed from http://www.xpdfreader.com/
>> the xpdf-tools-mac-4.02
>> and using the Terminal with „pdftotext /Users/hillen/Desktop/inter.pdf“
>> I get a clean text-file inter.txt. Wonderful!
>>
>> So I hopefully wrote in Livecode:
>>
>> ——————
>> put "/users/hillen/Desktop/inter.pdf" into fn
>> put "pdftotext " & fn into Kommando
>>
>> if there is not a file fn then
>> answer „no SourceFile!"
>> exit to top
>> end if
>>
>> get shell(quote & Kommando & quote)
>>
>> answer it & return & the result
>> ——————
>>
>> But extracting doesn´t work and I get the answer:
>>
>> /bin/sh: line 1: pdftotext /users ……pdf: No such file or directory
>>
>> and the result ist 127.
>>
>>
>>
>> Typing to Terminal „pdftotext“ I get a List with command-options.
>>
>> With
>> get shell(„pdftotext“) with and without quotes
>>
>> I get the answer „/bin/sh: line 1: pdftotext: command not found“
>>
>>
>>
>> What is wrong? May you please help?
>>
>> Richard.
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

--
Phil Davis
503-307-4363


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: shell() and pdftotext

Stephen Barncard via use-livecode
To elaborate further, if you can use pdftotext from the command line, but this is failing, it is because the path declared for your login shell is not getting picked up, or a different shell is being used by livedcode.

Come to think of it, I have *no* idea which shell livecode defaults to—I’d assume the system default, which sometimes varies over versions of a particular OS.

So if you use tcsh, but your system defaults to bash, all of those customizations and variables that apply at the command line may not come into play.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: shell() and pdftotext

Stephen Barncard via use-livecode
Shell() always uses the default folder path. Example (mac/Linux):

Set the defaultFolder to specialFolderPath(“home”)
put shell(“ls”)
Breakpoint
Set the defaultFolder to specialFolderPath(“documents”)
put shell(“ls”)
Breakpoint

I put any non native shell commands I want into my engine path, especially for standalones.

Sean Cole
Pi Digital Prod Ltd

> On 13 Jan 2020, at 18:25, doc hawk via use-livecode <[hidden email]> wrote:
>
> To elaborate further, if you can use pdftotext from the command line, but this is failing, it is because the path declared for your login shell is not getting picked up, or a different shell is being used by livedcode.
>
> Come to think of it, I have *no* idea which shell livecode defaults to—I’d assume the system default, which sometimes varies over versions of a particular OS.
>
> So if you use tcsh, but your system defaults to bash, all of those customizations and variables that apply at the command line may not come into play.
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: shell() and pdftotext

Stephen Barncard via use-livecode
In reply to this post by Stephen Barncard via use-livecode
> Richard H. wrote:
> Typing to Terminal „pdftotext“ I get a List with command-options.
> With get shell(„pdftotext“) with and without quotes
> I get the answer „/bin/sh: line 1: pdftotext: command not found“
> What is wrong? May you please help? (MacOS Catalina).

You could add on startup /usr/local/bin
to the LC environment variable $PATH:

on startUp
  local ulb="/usr/local/bin"
  set itemdel to ":"
  if ulb is not among the items of $PATH
  then put ":"&ulb after $PATH
end startUp
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode