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 7051189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:14:02+00:00 2026-05-28T03:14:02+00:00

I have some AppleScript code that I’m executing with osascript . This is part

  • 0

I have some AppleScript code that I’m executing with osascript. This is part of a larger Perl program. I’d like to be able to print to stdout from the AppleScript, then have the Perl script process the output. But I haven’t been able to print from within AppleScript. What should I do?

Here’s what I’ve tried:

  • do shell script "echo Foo". Does not ouptut Foo.
  • This Google Groups discussion does some trickery to open /dev/fd/1. For me, I get an error of “File Macintosh HD:dev:fd:1 wasn’t found”

Here’s the script I’m running:

tell application "Safari"
        set window_list to every window
        repeat with the_window in window_list
                set tab_list to every tab in the_window

                repeat with the_tab in tab_list
                        set the_url to the URL of the_tab
                        -- I'd like to put a print statement here,
                        -- instead of display dialog
                        display dialog the_url
                end repeat
        end repeat
end tell

Since osascript will automatically print the last value of a program, I could collect the URLs into a list and print that. But then my Perl script would have to parse the list, remove quotes, etc. It seems like it should be more straightforward to just print one URL per line.

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-05-28T03:14:03+00:00Added an answer on May 28, 2026 at 3:14 am

    I don’t know how to do what you’re asking and I don’t know Perl, however I think you could make the parsing from perl simple if you collect your urls in a string instead of a list. Each url would be on a separate line of the string. Perl should be able to turn that into an array pretty easily and then do something with it. Something like the below applescript. Of course you can use a different separator in the applescript. I used “return” but it could just as easily be a “comma” or any other character you want. Whatever is easiest for you in perl to change the string to an array.

    set urlString to ""
    
    tell application "Safari"
        set window_list to every window
        repeat with the_window in window_list
            set tab_list to every tab in the_window
    
            repeat with the_tab in tab_list
                set the_url to the URL of the_tab
                set urlString to urlString & the_url & return
            end repeat
        end repeat
    end tell
    
    return text 1 thru -2 of urlString
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some perl code that looks something like this: my @array = map
I have some code like this in a winforms app I was writing to
I have some classes layed out like this class A { public virtual void
I have been trying to write some applescript that checks to see if the
I have a plain text file looking like this: some text containing line breaks
Have some Perl code which is using the DBI module - (the code is
Have some problems with NSIS uninstall code. RMDir /r $SMPROGRAMS\${PRODUCT_NAME} In Windows 7 this
I have some UI in VB 2005 that looks great in XP Style, but
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
We have some input data that sometimes appears with &nbsp characters on the end.

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.