Sponsored Content
Top Forums Shell Programming and Scripting How to use javascript code in unix shell? Post 302599226 by Corona688 on Thursday 16th of February 2012 12:42:07 PM
Old 02-16-2012
The " inside the javascript will be eaten by the shell because they're not escaped. It doesn't know the quotes are supposed to be for javascript, and handles them itself.

Code:
$ echo " window.status = "Redirecting..." + myvar;"
 window.status = Redirecting... + myvar;

$ echo " window.status = \"Redirecting...\" + myvar;"
 window.status = "Redirecting..." + myvar;

$

...but it'll be more efficient and far less typo-prone to do this in a here-document, that will let you plunk it down nearly verbatim:

Code:
cat <<EOF
<script type="text/javascript">"
function exec_refresh()
{
window.status = "Redirecting..." + myvar;
myvar = myvar + " .";"
var timerID = setTimeout("exec_refresh();", 100);
if (timeout > 0)
{
timeout -= 1;
}
else
{
clearTimeout(timerID);
window.status = "";
window.location = "Test.com Web Based Testing and Certification Software v2.0";
}
}
var myvar = "";
var timeout = 20;
exec_refresh();
</script>
EOF

${VARIABLES} and `backticks` will still be substituted inside a here document. Escape ` and $ with \ to avoid it.

Note the ending EOF must be at the beginning of the line, not indented!
This User Gave Thanks to Corona688 For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling Shell script in javascript

All I want to call a KORN shell script inside a javascript. Is it possible ? Please help me to do this. I want to return or read from shell script in javascript. Thanx in advance Regards Deepak Xavier (1 Reply)
Discussion started by: DeepakXavier
1 Replies

2. Cybersecurity

Function of Javascript within Unix Network

What attacks can a Unix box get through Javascript? Is the Web Client secure against Javascript attacks if any? Do we have a Trojan horse made in JavaScript? (3 Replies)
Discussion started by: netass
3 Replies

3. Shell Programming and Scripting

clear complex javascript code

Hi, Please advise how can we clear the following javascript content from a file commandline, probably using awk or sed File before removing the content. ################################ root@server1 # cat index.html This is a test page <script language=JavaScript>function d(x){var... (6 Replies)
Discussion started by: fed.linuxgossip
6 Replies

4. Web Development

Javascript -> Shell Script

Hi all, I am trying to call a shell script from a javascript function. This works fine and the shell script returns everything I expected BUT I cannot figure out how to pass command line arguments to this shell script. Using GET, I assume the url being called needs to be one string with no... (7 Replies)
Discussion started by: mark007
7 Replies

5. Homework & Coursework Questions

Report on Javascript attacks on Unix

1. The problem statement, all variables and given/known data: Prepare a report discussing from an administration and security perspective, role and function of a JavaScript within a UNIX network. You should illustrate your answer with practical examples. In particular attention should me paid to... (1 Reply)
Discussion started by: afdesignz
1 Replies

6. Shell Programming and Scripting

want to use javascript as shell script

<html> <head> <title>Weather & Aviation Page - METAR decoder</title> <meta name="Title" content="Weather & Aviation Page - METAR decoder"> <meta name="Keywords" content="METAR decoder"> <meta name="Publisher" content="SkyStef"> <meta name="Description" content="SkyStefs weather and aviation... (4 Replies)
Discussion started by: anuajay1988
4 Replies

7. Shell Programming and Scripting

How to use JavaScript in UNIX Shell scripting?

I want to navigate through a webpage and save that page in my system local automatically. How can I do that by using JavaScript in a Unix shell script. Any suggestions are welcome! (3 Replies)
Discussion started by: abhi3093
3 Replies

8. Web Development

JavaScript code - UNIX grep?

Hi I am new to JavaScript & haven't done much work with it, but have mainly experience with UNIX. I have a piece of code where I want to grep (excuse the UNIX language :D) for a id and get the number from that. { "time": 900, "avail": 1, "price": 0, "datetime":... (8 Replies)
Discussion started by: simpsa27
8 Replies
glutVisibilityFunc(3GLUT)					       GLUT						 glutVisibilityFunc(3GLUT)

NAME
glutVisibilityFunc - sets the visibility callback for the current window. SYNTAX
void glutVisibilityFunc(void (*func)(int state)); ARGUMENTS
func The new visibility callback function. DESCRIPTION
glutVisibilityFunc sets the visibility callback for the current window. The visibility callback for a window is called when the visibility of a window changes. The state callback parameter is either GLUT_NOT_VISIBLE or GLUT_VISIBLE depending on the current visibility of the window. GLUT_VISIBLE does not distinguish a window being totally versus partially visible. GLUT_NOT_VISIBLE means no part of the window is visible, i.e., until the window's visibility changes, all further rendering to the window is discarded. GLUT considers a window visible if any pixel of the window is visible or any pixel of any descendant window is visible on the screen. Passing NULL to glutVisibilityFunc disables the generation of the visibility callback. If the visibility callback for a window is disabled and later re-enabled, the visibility status of the window is undefined; any change in window visibility will be reported, that is if you disable a visibility callback and re-enable the callback, you are guaranteed the next visibility change will be reported. SEE ALSO
glutCreateWindow, glutPopWindow AUTHOR
Mark J. Kilgard (mjk@nvidia.com) GLUT
3.7 glutVisibilityFunc(3GLUT)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy