Re: Passing argumenst to C executable from Apple script
Re: Passing argumenst to C executable from Apple script
- Subject: Re: Passing argumenst to C executable from Apple script
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 18 Apr 2008 08:32:17 -0400
If it's named "MyTest.exe", then "./MyTest" won't work. OS X is not Windows
How are you running the script? I don't think you can safely assume
anything about the current working directory in AppleScript - you will
have to use "path to me" and friends to build an absolute path to
MyTest.
AppleScript has no access to execv*() directly; you have to go through
the shell. Build a command line by concatenating the full path to
MyTest with the quoted forms of the arguments together into a string
separated by spaces, and then run that command line via "do shell
script".
Example:
set prefix to POSIX path of (path to me as alias)
set arg1 to choose file with prompt "first file"
set arg2 to choose file with prompt "second file"
do shell script "\"$(dirname " & quoted form of prefix & ")\" " &
quoted form of POSIX path of arg1 & " " & quoted form of POSIX path of
arg2
But Xcode has much better ways of accomplishing the goal of "prompt
the user for files and then run this C code on them".
On 4/18/08, SVV Satyanarayana <email@hidden> wrote:
> I have directory "Test" which consists of MyScript.scpt (Apple script
> file created from script editor) and an executable MyTest.exe
> (compiled C program).
> MyTest.exe takes two parameters as arguments. (Example to run it "./
> MyTest name age")
> MyScript.scpt must show a dialog to accept two parameters and when
> user presses OK button, it must call my MyTest executable with
> necessary data from script.
>
> I think I gave clear description now.
> please revert back if not clear.
>
> SVV Satyanarayana
> Bangalore, India
>
>
> On 18-Apr-08, at 1:30 PM, Philip Aker wrote:
>
> > On 08-04-17, at 21:57, SVV Satyanarayana wrote:
> >
> >> From Apple script, I am showing a dialog with few textboxes and a
> >> button. On click of the button, I want to call some "C" executable
> >> with arguments as strings in textboxes. How can I do this?
> >
> > To call command line tools, use the 'do shell script' command.
> > Details are in the Standard Additions dictionary.
> >
> > It's not clear from your post whether or not you are in an
> > AppleScript Studio project and whether or not you are targeting a
> > tool or a scriptable application.
> > To target a scriptable application use the form:
> >
> > tell application "System Events"
> > activate
> > set flist to path of every file of desktop folder whose visible is
> > true
> > choose from list flist
> > end tell
> >
> > Philip Aker
> > echo email@hidden@nl | tr a-z@. p-za-o.@
> >
> > Sent from my SE/30
> >
>
>
--
Sent from Gmail for mobile | mobile.google.com
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden