Shell can't find AWS

I’m trying to use AWS Textract for OCR, and have installed its CLI package under MacOS Monterey. If I paste my command into Terminal it works fine:

aws textract detect-document-text --document '{"S3Object":{"Bucket":"mybucketname","Name":"testpic.jpeg"}}'

But no matter how I break up my Xojo Shell’s command and parameters, I always get error 127
bash: aws: command not found.

I’ve tried sending everything in the shell’s command parameter, I’ve tried just “aws” in the command and everything else in the parameters, and breaking it at other points e.g. after “textract”, etc.

It’s not a syntax thing because my Xojo code puts a string on the clipboard and if I paste that into Terminal it works. I’d suspect a path / environment variable type issue, but if Terminal can find the aws executable, why can’t the Xojo shell?

dim shellcmd As String = "aws"
dim shellParms As String = "textract detect-document-text --document "+objstr

// Copy to clipboard for pasting into Terminal for comparison
dim terminalcommand As String = shellcmd+" "+shellParms
dim c As new Clipboard
c.Text = terminalcommand

Shell1.ExecuteMode = shell.ExecuteModes.Synchronous
Shell1.Execute shellcmd, shellParms


For the Xojo shell you have always needed to add the full path for the CLI tool you want to use.

Sheesh, how primitive :roll_eyes: Thanks!

Hi Julia,

I’m not on OSX so cannot check what they use as the current shell. Try changing the backend to sh or bash.

Var sh As New Shell
sh.Backend = “bash”
TextArea1.Text = sh.Result

1 Like

you can make it advanced:

'If the shell is interactive:
Var path As String = System.EnvironmentVariable("PATH")
sh.execute("export PATH="+path)
'If the shell is sync:
Var cmd As String = "your command"
Var path As String = System.EnvironmentVariable("PATH")
sh.execute("export PATH="+path+";"+cmd)

You basicly copy your current user path to the shell.
May vary per platform

Julia… I have xojo classes for accessing AWS ML services including Textract… no CLI, shell or Plugins required… Let me know if you want a copy via PM.

1 Like