LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-18-2011, 02:57 AM   #1
athrin
Member
 
Registered: Mar 2011
Posts: 135

Rep: Reputation: 1
javascript and bash


hi,

can i pass javascript variables to bash script??
if can in bash script what code should i insert to receive javascript variables
 
Old 04-18-2011, 03:03 AM   #2
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
i know that you can pass SCRIPT (shell, bash, ...) variables into other script variables
like so:

script.sh
Code:
echo test
script2.sh
Code:
VAR=`./script.sh`

echo $VAR
this should NORMALLY work (i used it with ssh connections -> VAR=`ssh user@host ./sript.sh` and it worked for me so...)
maybe you should give this a try and give some feedback
 
Old 04-18-2011, 03:05 AM   #3
shane_kerr
LQ Newbie
 
Registered: Oct 2005
Location: Amsterdam, Netherlands
Posts: 15

Rep: Reputation: 2
This is a slightly confused question. Javascript typically runs in a browser, and bash is usually a command line interpreter.

Maybe you can explain what you are doing and then we can figure out if it is possible.
 
Old 04-18-2011, 03:06 AM   #4
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
i know that you can pass SCRIPT (shell, bash, ...) variables into other script variables
like so:

script.sh
Code:
echo test
script2.sh
Code:
VAR=`./script.sh`

echo $VAR
this should NORMALLY work (i used it with ssh connections -> VAR=`ssh user@host ./sript.sh` and it worked for me so...)
maybe you should give this a try and give some feedback
why are you using two bash script?
 
Old 04-18-2011, 03:07 AM   #5
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by shane_kerr View Post
This is a slightly confused question. Javascript typically runs in a browser, and bash is usually a command line interpreter.

Maybe you can explain what you are doing and then we can figure out if it is possible.
in my javascript prompt to ask location. and in my bash script will display the output
 
Old 04-18-2011, 03:09 AM   #6
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
Quote:
Originally Posted by athrin View Post
why are you using two bash script?
i didn't say it was a solution... i know something like that worked for me and maybe you should try in YOUR BASH script something that executes your javascript?!
So the result of your javascript would be put in a variable which you can display on your cmd

---------- Post added 04-18-11 at 09:09 AM ----------

Quote:
Originally Posted by athrin View Post
in my javascript prompt to ask location. and in my bash script will display the output
to ask location? location of what? in which folder you are in or what pc you're logged on or on what site you are on or ....?????
 
Old 04-18-2011, 03:10 AM   #7
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
to call bash is this code correct??

Code:
window.location.href = "http://localhost/script.sh?width=" +"$height";
 
Old 04-18-2011, 03:14 AM   #8
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
i didn't say it was a solution... i know something like that worked for me and maybe you should try in YOUR BASH script something that executes your javascript?!
So the result of your javascript would be put in a variable which you can display on your cmd

---------- Post added 04-18-11 at 09:09 AM ----------



to ask location? location of what? in which folder you are in or what pc you're logged on or on what site you are on or ....?????
haha.. sorry i made you confuse.. that just an example.. the easier example.. i ask a name using prompt box in javascript and that name will be display inside bash. that all..
 
Old 04-18-2011, 03:17 AM   #9
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
Quote:
Originally Posted by athrin View Post
haha.. sorry i made you confuse.. that just an example.. the easier example.. i ask a name using prompt box in javascript and that name will be display inside bash. that all..
so in a website somebody fills in his/her name and that will be displayed inside bash ?
 
Old 04-18-2011, 03:20 AM   #10
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
so in a website somebody fills in his/her name and that will be displayed inside bash ?
yes ^_^
 
Old 04-18-2011, 03:21 AM   #11
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
can you show us some code?
 
Old 04-18-2011, 03:26 AM   #12
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
can you show us some code?
errr....

javascript
Code:
<script type = "text/javascript">

	var name;
	
	name = prompt("Enter name : ", " ");
</script>
err.. i still dont know how to pass this name to bash and also how bash will receive the name.
 
Old 04-18-2011, 03:50 AM   #13
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
if cant its ok.. thanks anyway ^_^
 
Old 04-18-2011, 03:54 AM   #14
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
yeah, i'm out of suggestions

anyway, good luck with it
 
Old 04-18-2011, 04:01 AM   #15
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
beside javascript what will you use? you seems know what i want right?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Textbrowser with JavaScript Support or Elink Javascript Support rohezal Linux - Software 4 09-01-2009 02:02 PM
Ubuntu Edgy/Firefox 2/Javascript - Firefox closes accessing websites with Javascript Interdictor Ubuntu 8 11-02-2006 12:58 PM
Need help on Javascript jun_tuko Programming 3 01-16-2006 04:45 AM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 08:53 AM
Javascript maseby Programming 1 04-09-2004 06:16 PM


All times are GMT -5. The time now is 06:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration