• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Passing argumenst to C executable from Apple script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing argumenst to C executable from Apple script


  • Subject: Re: Passing argumenst to C executable from Apple script
  • From: SVV Satyanarayana <email@hidden>
  • Date: Sat, 14 Jun 2008 14:12:47 +0530

do shell script "\"$(dirname " & quoted form of prefix & ")\" " &
quoted form of POSIX path of arg1 & " " & quoted form of POSIX path of
arg2

In the above example mentioned, if I want to pass "path of some file" as argument, I have to use "quoted form of POSIX path of arg 1"  etc.
But what if I want to pass some integer values or strings as an argument?

SVV Satyanarayana
Novell Software Development IDC
Phone: 91-80-2573 1856 Ext:2671
Mobile: 91-988 655 5469
Bangalore, India
P Please consider the environment 
before printing this email.

On 18-Apr-08, at 6:02 PM, Mark J. Reed wrote:
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

  • Follow-Ups:
    • Re: Passing argumenst to C executable from Apple script
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: Spam
  • Next by Date: Re: Running ruby (utilizing appscript) from do shell script
  • Previous by thread: Re: Spam
  • Next by thread: Re: Passing argumenst to C executable from Apple script
  • Index(es):
    • Date
    • Thread