Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MikePancho

macrumors newbie
Original poster
Dec 20, 2012
4
0
if there any way you can copy the text from "text file #1" into safari's web console using a .sh file?
thanks
-- Mike
 
Safari's Console is an output-only error-message console. It's not a command interpreter.

Terminal.app is where you can input commands in a window and see their output.


Please explain exactly what you're trying to accomplish, that you think Safari's console is the solution.

You've posted an XY Problem, where you want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.
http://www.perlmonks.org/?node_id=542341
 
Actually it is, apart from commands, you can execute Javascript and interact with the DOM and see the effects as you type.
I've never seen this. Please describe exactly which window or pane this is, and the menu-items or other commands that cause it to appear.

And which version of Safari does this appear in.

I have both the Develop and Debug menus enabled in my Safari versions, and nothing I've yet seen brings up such a "console".
 
I've never seen this. Please describe exactly which window or pane this is, and the menu-items or other commands that cause it to appear.

And which version of Safari does this appear in.

I have both the Develop and Debug menus enabled in my Safari versions, and nothing I've yet seen brings up such a "console".

Open the WebInspector, press 'console' in the upper right corner, alternatively the lower left corner with the '>' symbol for a split view.

For a demo on this page try this:

Code:
$('body').css('background-color', 'red')

Edit: Also from Apple's documentation, "The console offers a way to inspect and debug your webpages. Think of it as the Terminal of your web content. The console has access to the DOM and JavaScript of the open page. Use the console as a tool to modify your web content via interactive commands and as a teaching aid to expand your knowledge of JavaScript."
 
Open the WebInspector, press 'console' in the upper right corner, alternatively the lower left corner with the '>' symbol for a split view.

For a demo on this page try this:

Code:
$('body').css('background-color', 'red')

Edit: Also from Apple's documentation, "The console offers a way to inspect and debug your webpages. Think of it as the Terminal of your web content. The console has access to the DOM and JavaScript of the open page. Use the console as a tool to modify your web content via interactive commands and as a teaching aid to expand your knowledge of JavaScript."

Thanks for that, I hadn't noticed it before.

For future readers of this thread, Apple's Safari Console guide is here (for now):
https://developer.apple.com/library...l/Safari_Developer_Guide/Console/Console.html


So getting back to the OP's question...

I think he's asking if he can write a shell script that tells Safari to open its Web Inspector window, then copy and paste some series of commands from a text-file into that window's console pane. The pasted commands would presumably be valid Safari-console commands, rather than, say, shell commands, or /bin or /usr/bin commands.

The first step of an answer to that might be getting the contents of the text-file into the system clipboard. One way to do that is the 'pbcopy' command:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html
Simple example:
Code:
pbcopy <"path/to/your/text file #1"
The logical next steps would be to tell Safari to:
1. Open its Web Inspector window.
2. Activate the console pane.
3. Paste the clipboard.
4. Press return.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.