Is it possible to call javascript inside a shell script? For example,
echo "Content-type: text/html"
echo "
<html>
<script type="text/javascript">
document.write("<p>" + Date() + "</p>");
</script>
</html>
"
Is it possible to call javascript inside a shell script? For example,
echo "Content-type: text/html"
echo "
<html>
<script type="text/javascript">
document.write("<p>" + Date() + "</p>");
</script>
</html>
"
Share
Improve this question
edited May 11, 2011 at 14:48
thetux4
asked May 11, 2011 at 14:16
thetux4thetux4
1,63310 gold badges28 silver badges38 bronze badges
1
- What would you expect to happen if you could? This could be answered in so many different ways depending on what you're trying to do. – John Kugelman Commented May 11, 2011 at 14:18
4 Answers
Reset to default 3By default: No. But you could install applications that can run javascript like node.js or rhino.
If your script is used by CGI (Common Gateway Interface) application, then yes, you can include HTML with embedded JavaScript.
EDIT: JavaScript is a client-side technology. You won't get any trace of JavaScript running on server, because it won't be executed on server (unless we're talking about Server Side JavaScript but I don't think so).
Try RhinoShell.
You'll need to install a javascript engine on your system to be able to call it from bash and execute your javascript code. Check SpiderMonkey.