'How to call a php file with arguments from VBA for Mac? Equivalent of VBA.createObject("wscript.shell") on Mac?

Still in need of help :)

I'm trying to adapt the following chunk of code to VBA for Mac (as the final implementation has to be on Mac):

Dim ws as Object
Dim result as String
Set ws = VBA.CreateObject("wscript.shell")
cd = "php " & dirPHP & "\verificar.php " & FileName
result = ws.Run(cd)
Set ws = Nothing

It runs perfectly on Windows, but when trying to adapt it for Mac I'm encountering many problems.

What I am basically doing on the previous chunk is calling a PHP file that takes the first argument (in this case, FileName) and calls the verify function, returning some values.

The thing is that there are some posts explaining how to do this, but I have seen no examples on how to do it for PHP, and especially for PHP passing an input argument.

This is what I've tried so far:

  1. result = AppleScriptTask("PHPCommand.applescript", "PHPCommandHandler", FileName)
  2. e = "php " & dirPHP & "/verificar.php " & FileName cd = "do shell script """ & e & """" result = MacScript(cd)

(On the Mac Terminal I am able to run the PHP file fine, with the resulting "e" string).

  1. And some other fruitless things, like the shell() function, or some other user-defined functions (I saw someone defined a "system()" function). I also tried many ways of putting the double and simple quotes, and simplified the path to the PHP file (dirPHP) and the path + filename of the argument (FileName) by removing all blank spaces and thus the need of using additional quotes.

Please help me! I'd be really grateful, as yesterday I spent the whole day on this and I can't keep wasting time on something that is so simple on Windows... But I have to do it on Mac.

Thanks so much!!!



Solution 1:[1]

Use the VBA Shell function.

Shell

Runs an executable program and returns a Variant (Double) representing the program's task ID if successful; otherwise, it returns zero.

Syntax

Shell(pathname, [ windowstyle ])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user18521918