The Ashes

Technology, Science and other news
September 3, 2009

JavaScript on the command line or as a shell scripting language

Posted by : admin
Filed under : General

I am always fascinated that no matter how shiny the OS, sooner or later you’ll end up typing things into a text console to get the darn machine to do what you want it to. To make matters worse you also have to resort to languages that you don’t use every day but are from cryptic days of development where keyboards obviously had more interesting characters like ~ | — and others easily available and scripts had to have numerous | in any line of code.

Enter Stoyan Stefanov who wrote a neat little blog post explaining how you can use JavaScript as a shell language.

In essence, Rhino is the answer for *nix machines but if you cuddle the penguin you most likely are a shell master anyways.

If your world features Gates and Windows, then there is the Windows Scripting Host, which has a tool to execute JavaScript on the DOS shell:

PLAIN TEXT
JAVASCRIPT:

  1. C:\> cscript jslint.js

Macs have a tool called JSC which is “conveniently” located in:

PLAIN TEXT
JAVASCRIPT:

  1. /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc

To make it human usable, creating a shortcut is a good plan:

PLAIN TEXT
JAVASCRIPT:

  1. $ sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc

You can then execute JavaScript by starting JSC which gives you something like the Firebug JS console in the OS console (without the console is not defined messages *in* the console).

With a few more lines using the print(), quit() and load() commands available on the shell you can then use any JavaScript to mess with your files and folders.

Tags :

No Comments

(required)
(will not be published) (required)
(opitional)

cciash.com EN ES IT DE PT CZ FR RU
December 2017
M T W T F S S
« Sep    
 123
45678910
11121314151617
18192021222324
25262728293031

Pages

Categories

Resources

There are many online poker site where you can play but at poker.hk you can play the poker games with all the knowledge you need related to the game with the poker school available in both the English and Chinese language.

Super Casino

Now you can bet on any sports and any sporting events from all the comfort from your home. Bet770 allows you to bet on any events and match with in just 3 clicks. They also offers great odds on football betting for every premier and champions league match. Get £50 free in bets when you register.

Bingo770, offering best online bingo games with £7.70 free no deposit Bonus!