Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

What can software can I install so that I can run Javascript files from the terminal.app?

I've seen you-tube footage where the user executes JS code from terminal like the way you can simply run a Ruby file if you have Xcode installed. I'd like to be able to simple run a .js file from terminal or run it from say, TextWrangler and have runtime fail line error's returned the way the they are with ruby code files. This is my preference to running JS code in a browser.

Posted on Apr 9, 2012 2:57 AM

Reply
Question marked as Best reply

Posted on Apr 9, 2012 3:47 AM

Node.js perhaps.

12 replies

Apr 9, 2012 9:17 AM in response to sptrakesh

sptrakesh wrote:


I think OP is referring to a visual terminal equivalent someone had developed using Node.js. I do not remember name of it though, but I remember having read about it a few months ago.

In the spirit of Apple Support Communities, I don't want to have to go Google Node.js myself. I want someone to give me the link! 🙂

Apr 10, 2012 7:44 AM in response to etresoft

Javascript seems heavily dependent on the DOM.

Yes but it's also a scripting language in it's own right...

It doesn't have any I/O capabilities.

Then node.js is in trouble as a server side JS replacement for php scripts isn't it! The method I am using ATM is just to embed a data object in JSON format.

ie data =

[

["foo","bar"],

["lah","lah],

]


I have a CSV file I manually converted using GREP find&replace commands in TextWrangler.


I might go for HTML or some other environment (Apple's QC) where I can generate interaction/outputs when I get my script up to scratch. I'm just trying to parse the data for duplicate records but need to merge duplicates in case by case way... Starting to think Applescript in Excel might be preferable since the CSV->JSON manual conversion was a pain. There seem to be scripts to do CSV conversion to an array on stackoverflow.com

Apr 10, 2012 8:16 AM in response to wideEyedPupil

wideEyedPupil wrote:


Javascript seems heavily dependent on the DOM.

Yes but it's also a scripting language in it's own right...


I know and I'm quite fond of it. I didn't used to be but it is growing on me. Still, it runs in the context of a web browser, as far as I know. My comment above asking for a link was only half in jest. This week is awfully busy for me. If I can remember it by next Tuesday, I will then have a chance to look at it.



It doesn't have any I/O capabilities.

Then node.js is in trouble as a server side JS replacement for php scripts isn't it! The method I am using ATM is just to embed a data object in JSON format.

ie data =

[

["foo","bar"],

["lah","lah],

]


I have a CSV file I manually converted using GREP find&replace commands in TextWrangler.


I might go for HTML or some other environment (Apple's QC) where I can generate interaction/outputs when I get my script up to scratch. I'm just trying to parse the data for duplicate records but need to merge duplicates in case by case way... Starting to think Applescript in Excel might be preferable since the CSV->JSON manual conversion was a pain. There seem to be scripts to do CSV conversion to an array on stackoverflow.com



I try to avoid AppleScript because I don't have much good to say about it. Perhaps you should explain exactly what you want to accomplish. CSV and JSON shouldn't be a pain. Both were created because they were fall-of-a-log easy.

Apr 10, 2012 8:53 AM in response to wideEyedPupil

Applescript is part of the Open Scripting Architecture the idea when it was designed was that Applescript should be available on other platforms other then Apple. Conversely any scripting language that conforms to OSA can run on a Mac.


Not much came of all this but OSA is still in there and JavaScript OSA will (supposedly) allow JavaScript to run just as Applescript does. It even (supposedly) supports Apple Events.


Finally this should even work in the Script Editor, JavaScript will appear as another scripting language in the editor.


regards

Apr 20, 2012 7:11 AM in response to wideEyedPupil

I recently had an "ah ha!" moment with Applescript when I tried to write some Flashback remover script. I discovered that in order to take a path and convert it into a file that the Finder could understand, I had to cast it to a string first.


That is why I have such a hard time with Applescript. Anyone who has experience with a real programming language would never think to try casting a string to a string before using it. That's just wrong. That's just Applescript.

What can software can I install so that I can run Javascript files from the terminal.app?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.