Sponsored Content
Homework and Emergencies Homework & Coursework Questions Passing shell variables to a webpage Post 302581218 by Corona688 on Monday 12th of December 2011 11:30:01 AM
Old 12-12-2011
Quote:
Originally Posted by ChedWick
Here's the issue. I have both the client and the server side parts done but with place holder values on the client page. I'm having issues figuring out how to get them to talk or rather pass variables to each other.

For simplicity lets work with a simple example and I can then apply that to my project. Say I have a php page or even a simple html/javascript(if possible) page that a user accesses via their web browser. I want to print or alert the variable $A.
Does this variable actually exist anywhere, or is it just sitting in some file?

What do you need to be able to do with this variable?
Quote:
I have a server side shell script that simply assigns the variable $a to "hello."
Shell variables only make sense in a shell...

You could export the variable, then have your PHP executed like this:

Code:
# variable file

export A="asdf"

Code:
#!/bin/sh

. variablefile

/usr/lib/php5.3/bin/php <<EOF
<?php
        printf("variable A is %s\n", getenv("A")); ?>
EOF

exit

But I get the feeling you want to have more control over the variable than that, you need to set and retrieve it when you please, not just when first executed, and do so in a manner safe across several connections.

This is the sort of thing they usually use a database with. The combination of Linux, Apache, Mysql and PHP is so common they usually call it LAMP...

Last edited by Corona688; 12-12-2011 at 12:37 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing shell variables to awk program..

Hello, Can we pass shell variables like $PATH etc. to a awk program part for example, awk ' { fieldValue=$PATH .... }' file (1 Reply)
Discussion started by: Vishnu
1 Replies

2. Shell Programming and Scripting

passing two variables into a shell script?

Hello all, i have a infile.txt text file which contains such variables: aaa 123 asds 1323 asdsd 13434 lkjlkj 324324 23432 lkjlkj 24324 ljlkj 3j4lk 234kj3 and i want to pass them to my script such as: ./myscript $1 $2 where $1 is the first value in the first row and $2 is the second... (2 Replies)
Discussion started by: Bashar
2 Replies

3. Shell Programming and Scripting

Passing Shell Variables in ISQL

Hi.. I am passing a variable in my shell function. I need to access it for an isql comand in the shell script. However the isql o/p gives no results if i pass a variable in the command. The isql command works perfectly fine if i hardcore the table name. My script is : ... (0 Replies)
Discussion started by: dikki
0 Replies

4. Shell Programming and Scripting

Passing the nawk variables to the shell

nawk '($1 ~ "1000") && ($1 ~ "5665" ) { sub ($6,"89");flag =1;print }' old.txt >> new.txt I want to set a flag in awk , if the both conditions are met. I want to pass this flag to shell Can anyone please help me on this (1 Reply)
Discussion started by: prav076
1 Replies

5. Shell Programming and Scripting

Passing shell variables to a rsh command

I noticed my script is not passing the value of variable alert to the rsh command. I need some assistance, please. This is a solaris environement. Thanks! :confused: #!/bin/sh echo -n "Alert number:" read alert rsh rhost_name 'egrep $alert /opt/var/log/*.logs' (2 Replies)
Discussion started by: lopus
2 Replies

6. Shell Programming and Scripting

Passing gnuplot variables to shell script

Hi, I need to pass a gnuplot value to a shell script. I have a main shell script (Main.sh) that has a bunch of gnuplot commands. Main.sh calls another gnuplot script (Child.gnu). A part of the code in Child.gnu is as follows: sp '</data/src/scripts/results/plot_data.sh $col' u (A):2:3 w pm3d... (8 Replies)
Discussion started by: annazpereira
8 Replies

7. UNIX for Dummies Questions & Answers

Passing Shell Variables to an awk command

Hello, I have two files File1 & File2. File1 76 135 136 200 250 345 .... File2 1 24 1 35 1 36 1 72 .... I want to get all the values form File2 corresponding to the range in File 1 and feed it to a program. Is the code below right? Can I pass shell variables to awk in this... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

8. Shell Programming and Scripting

Passing awk variables to shell

Hi. I need to parse file and assign some values to variables, right now i do like below MYHOMEDIR=`awk '/Home/ {print $NF}' output.txt` MYSHELL=`awk '/Shell/ {print $NF}' output.txt` PRGRP=`awk '/Primary/ {print $NF}' output.txt` SECGRP=`awk '/Second/ {print $NF}' output.txt` In this... (10 Replies)
Discussion started by: urello
10 Replies

9. UNIX for Dummies Questions & Answers

Passing Global Shell variables to awk

Hi All, Iam trying to pass global shell variables and is not working Main script is like below CYEAR=`date +"%y"` CFYEAR=`date +"%Y"` CMONTH=`date +"%m"` if then PMONTH=12 PYEAR=`expr $CYEAR - 1` PFYEAR=`expr $CFYEAR - 1` else PMONTH=`expr... (6 Replies)
Discussion started by: baanprog
6 Replies

10. Shell Programming and Scripting

Passing information to a file on webpage

ok so I have a file on a website. this file is a plain text file i need to be able to update the contents of this file from any internet enabled unix box. does anyone have ideas on how it can be done, without using scp/ftp? i know wget can be used to download the file: wget... (3 Replies)
Discussion started by: SkySmart
3 Replies
X11START(1)						      General Commands Manual						       X11START(1)

NAME
x11start - start the X11 window system SYNOPSIS
x11start [options] DESCRIPTION
NOTE: Beginning with the next release of HP-UX, x11start and its components (xinit, sys.x11start, and sys.Xdefaults) will not be supported. vuelogin (an enhanced version of xdm) will perform all start-up tasks, regardless of whether or not HP-VUE is in use. See the HP Visual Environment User's Guide and the vuelogin man page for information on vuelogin. x11start is a shell script that provides a standarized method for starting up the X Window System server and selected X clients when the Visual User Environment (HP-VUE) is not used. Specifically, it performs the following start-up tasks: o PATH environment variable set-up appropriate for the X environment o X server start-up o selected client(s) start-up from a specific client file o general user resource loading from a specific resource file Components x11start encompasses the following components: o the /usr/contrib/bin/X11/x11start script o the /usr/contrib/bin/X11/xinit program o the default client script, /usr/contrib/lib/X11/sys.x11start o the default resouce file, /usr/contrib/lib/X11/sys.Xdefaults The x11start script o creates a command to load resources from the appropriate resource file using xrdb (see xrdb(1)) (This command is not executed immedi- ately but rather is assigned to the (exported) environment variable, doxrdb which is normally executed via the client script after the server has been started up.) o inserts /usr/bin/X11 ahead of /usr/bin in the PATH environment variable and appends /usr/vue/bin and /usr/contrib/bin/X11 to the end o execs xinit as follows (see xinit(1)): xinit clientscript options where clientscript is $HOME/.x11start or /usr/contrib/lib/X11/sys.x11start options are the xinit options exactly as specified on the x11start command line (see Options below). The xinit program o starts the server with the server arguments specified in options o runs the client script, passing it the client arguments specified in options o waits for either the server or client script to terminate and then terminates whatever remains running The default client script, /usr/contrib/lib/X11/sys.x11start o executes the environment variable, $doxrdb which was setup previously by x11start to load the appropriate resource file to the server o runs both mwm and hpterm with all client arguments specified in options o sleeps indefinitely so that the X Window System will not be shut down by xinit when all client script processes have terminated. The default resource file, /usr/contrib/lib/X11/sys.Xdefaults o sets the default Foreground, Background and BorderColor resources o contains sample resources for a number of common clients. Customized client and resource files can be created by copying the default files to $HOME/.x11start and $HOME/.Xdefaults, respectively, and then customizing them. Custom- ized files that exist (with the appropriate permissions) will be used by the x11start components in place of the default files. Options x11start options are the same as xinit options except that a client script cannot be specified. Arguments preceeding a "--" (double dash), or all arguments if "--" is not specified, are passed on to the client script and can be accessed as positional parameters within that script. Arguments following a "--" that begins with a slash (/) or a period (.) identify the server. If a server is not explicity specified, xinit determines the server from $DISPLAY if defined; otherwise from $XSERVERRC. If neither of these are defined, $HOME/.xserverrc is used if it exists and is executable; otherwise X :0 is used. Arguments following a "--" that don't begin with a slash or period are passed on to the appropriate server. See xinit(1) for more details. EXAMPLES
The following examples illustrate how x11start can be used to control the server and/or interact with the client script. x11start This starts the default xinit server and executes the client script (either /usr/contrib/lib/X11/sys.x11start or $HOME/.x11start) without passing arguments to either. x11start -bg black -fn 24x36 This starts the default xinit server and executes the client script, passing it all of the arguments. If the default client script is used, -bg black -fn 24x36 is be passed to both mwm and hpterm since both of their default command lines contain "$@". If the default client script is used, the actual xinit command executed is: xinit /usr/contrib/lib/X11/sys.x11start -bg black -fn 24x36 x11start -fg white -- :1 This starts the default server on display 1 and executes the client script with the arguments, -fg white. If the customized client script is used, the xinit command line is: xinit $HOME/.x11start -fg white -- :1 x11start -- Xhp -a2 -t 5 This starts the server, Xhp with the arguents, -a2 -t 5 and then executes the client script without any arguments. ENVIRONMENT VARIABLES
DISPLAY PATH XSERVERRC doxrgb FILES
/usr/contrib/lib/X11/sys.Xdefaults /usr/contrib/lib/X11/sys.x11start $HOME/.Xdefaults $HOME/.x11start $HOME/.xserverrc ORIGIN
HP SEE ALSO
X(1), xinit(1), hpterm(1), mwm(1), xrdb(1) X Version 11 Release 5 X11START(1)
All times are GMT -4. The time now is 09:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy