Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:36:35+00:00 2026-06-14T17:36:35+00:00

I’m very new to python and applescript. I have a python script which is

  • 0

I’m very new to python and applescript. I have a python script which is calling 2 applescripts. I would like to define few global variables in python and pass to applescript 1 , those values will be modified by different functions in applescripts 1, and pass back to python scripts, then pass those values to applescript 2 to use.

I have googled a bit and I tried the following:

in applescript,

on run argv 
    if (item 1 of argv is start with "x") then 
      function1(item1 of argv)
    else 
      function2 (item 1 of argv)
      function3 (item 2 of argv)
 end run

 on function1 (var)
  set var to (something code to get value from interaction with user)
 return var 
 end function1

in python script
import os
import sys

os.system ('osascript Setup.scpt')
variable1 = sys.argv[1]
variable2 = sys.argv[2]

in the applescript2, i did similar thing as applescirpt1.

However, this didn’t work. I tried to print out all the argv in both scripts, looks like the values are not correctly passed. Can anyone give me more direction on this? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:36:37+00:00Added an answer on June 14, 2026 at 5:36 pm

    os.system(): Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations.

    Changes to sys.stdin, sys.stout are not reflected in the environment of the executed command.
    The return value is the exit status, not the osascript output.

    Use subprocess.Popen:

    import os, sys, commands
    from subprocess import Popen, PIPE
    
    var1 = sys.argv[1] 
    var2 = sys.argv[2] 
    (var3, tError) = Popen(['osascript', '/Setup.scpt', var1, var2], stdout=PIPE).communicate()
    print var1
    print var2
    print var3
    

    The osascript command always returns a string.
    if the AppleScript return a list, the string in python will be separated by a comma and a space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to count the length of a string with PHP. The string
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.