Programming :: Accessing Global Variables In Script?

Apr 10, 2011

I have a script that goes like this

step 1 - install sdk

step 2 - update ~/.bashrc export some new variables

step 3 - check said variables, if they return a value then we know a reboot has taken place and we can continue to step 4. otherwise halt and isssue a warning that a reboot is needed.

Ok, so this works if I just execute the script when I am logged on as root, and after a reboot & rerun of the script I can check the variables exist and the program will continue as expected. only when I am logged on as root will the variables I exported in bashrc return a value. If I run the script as sudo root the values are blank.

View 2 Replies


ADVERTISEMENT

Programming :: Avoiding Global Variables In Kernel Modules?

Jun 27, 2010

I have two modules A and B in the kernel which i am trying to hack by introducing a variable in A which is of type 'extern' (and using EXPORT_SYMBOL) and then calling it in B. Now the problem is how to introduce that variable in module A. Currently i have made a global variable and it works fine but global variable in kernel is a bad bad thing.

I tried having an 'extern' function in A which have that variable and calling that function in module B, but then again how would module A use my variable unless the variable is available outside the scope of that function and that again means a global variable.

View 3 Replies View Related

Programming :: Global Or Server Variables - Array Connection Oriented

May 20, 2011

I have a general question regarding php. Suppose that I want to have an array that stores connection-specific data, that can be anything IP address or something similar. However, whenever I use global or server variables (i.e. GLOBALS or _SERVER) the array created in this way is kind of connection-oriented, so that for each connection there is a separate instance of this array. Maybe it has something to do with the MPM of Apache, but I am not sure. Is it possible to implement an array that stores information about all connections that are at a system? In this way, each connection can chip in and upload it with data? Also, I would rather not use cookie's.

View 3 Replies View Related

Programming :: PHP Accessing Variables Within Array

Mar 30, 2011

I am pretty new to PHP so excuse my dumbness. I've searched this up in quite a few places and cant find anything : Basically, I've made an array, within it are 3 more arrays. Their are two values in each array, 'Name' and 'Age'. Basically I am using a While statement to try and cycle through the 'age' value of my array and state whether or not the person is eligible. (I am actually just learning so I'm doing this to just test myself).

Here is my code
Code:
<?php
$people =array(
array('name' => 'Bob', 'age' => 15 ),
array('name' => 'Jhon' , 'age' => 10),
array('name' => 'Sue' , 'age' => 7));
//($value =& $people[0,1,2][age] );

Here was an attempt to try and create a reference to age, I tried it many different ways
while($age < 10) {
echo ('$name, is eligible') ; } ?>

Okay, so I tried to do this through two ways, one way I tried to create a reference to age, then evaluate it, without that line of code their would be no reference, which way is correct, why wont it work? I am using Xammp, so when I launch local host I get an undefined variable error. What To Do?

View 3 Replies View Related

General :: Declare Global Variables In Bash?

Jan 23, 2010

I have a problem with a very big script I wrote in bash, and now I need to modulirize it in at least four smaller scripts. The problem is, that most of the variables I have will need to be shared by all scripts.

My question is: is there a way to declare global variables in bash? So that I can use and change them in any of the scripts and every change in the variable can be "seen" by the other scripts later.

View 4 Replies View Related

Red Hat :: Global Variables Not Taking Effect When Set Via Called Script

Aug 3, 2010

I have a script which lists all the SID listed in /etc/oratab and then after the user select which SID to set, it calls another script to set the SID and other environment variables.

The script runs just fine and does all that is expected, but the variables are not set permanently, can't figure out why. Everything works fine when I run the setsid.sh out of this script.

Here is the script:

View 9 Replies View Related

Programming :: Define All Variables In Tcl Programming In A File For Instance Var.cfg?

Apr 27, 2010

I can define all variables in tcl programming in a file for instance var.cfgand source the same file in my tcl script such assource var.cfgIs this possible in perl too?

View 3 Replies View Related

Programming :: NameError: Global Name 'set' Is Not Defined

Apr 17, 2011

I have a Red Hat 4.9 server running python 2.3.4. However I need some of the new functions so I downloaded and installed Python 2.7.1. I wanted to use the "set" function which was not in the earlier version.

/bin/python is 2.3.4
/usr/local/bin/python is 2.7.1

I have a script running 2.3.4 which calls the 2.7.1 script however it fails because it cannot find the "set" command here is an example

Script1
#!/bin/python
import Mytest

[code]....

The error message is :

NameError: global name 'set' is not defined

View 14 Replies View Related

Programming :: How To Set Up Global Class In JAVA?

May 10, 2011

I've had to do some code in java, a language I'm very much unfamiliarly with so please excuse my incorrect use of terms. The basic outline of my problem is I create a class object as a local within a swing button function it works fine. If I create it as a global ( with I think I need to do ) within main, then prototype it with the other swing objects at the bottom of the file when it is called it causes a host of problems. I think the easiest way is to show it.

View 2 Replies View Related

Programming :: Python - Global Name Not Defined

Jun 17, 2011

I found an interesting screencast online about how to make gtk Pyton apps. The thing is, though, the guy was using the interactive shell. I've been trying to get his code into a script, and have been having troubles.

Here's what I got:

Code:

It spits out the error "NameError: global name 'browser' is not defined"

I know I'm doing something wrong with how I'm telling it where to find "browser" and "text", but I can't figure out how to point it to the right place.

View 5 Replies View Related

Programming :: Create A Global Struct Variable With Predefined Member Values?

May 26, 2010

Is it possible to create a global struct variable with predefined member values?Only one instance of that struct is ever needed.

View 1 Replies View Related

Programming :: Global Bash Shell Functions - A.sh: Line 2: Echotm: Command Not Found

Sep 13, 2010

I wonder if there is anyway to make a user-defined bash shell function global, meaning the function can be use in any bash shell scripts, interactively or not. This is what I attempted:

Code:

$ tail -n 3 /etc/bashrc
echotm () {
echo "[`date`] $@"
}

[code]....

View 11 Replies View Related

Programming :: Setting Variables In C-shell?

Jul 12, 2010

I'm running into a problem when I try to set a variable to an awk output in c-shell. Right now my command is Code: set STR_MSG_TYPE = `awk -F{ '/msg_type/ {print $2}' <filename> | tr -d }'/''*' ` I then run echo to see what the output is and it returns blank, however, when I run the same awk command from the command line, I get an actual output of "MT-715". Am I setting my variable incorrectly? I do something similar using the date command to set a STR_DATE variable earlier in the code and it works fine and I use the same syntax.

View 1 Replies View Related

Programming :: C With Gcc: Are All Variables Defined Like Pointers

Sep 13, 2010

i'm practicing in very basic c programs using the gcc compiler.I found that when i create two variables let's say

Code:

int a,b and Code: a=15;
b=3;
a=b;
b--;

then a equals 2.I thought that this isn't normal in C isn't it?I haven't had the time to read the gcc documentation yet...so i think it has something to do with my compiler's default settings.I use the

Code: gcc filename.c -o filename command to compile

Are all variables defined like pointers?

View 5 Replies View Related

Programming :: How To Check For Empty Variables In PHP

Apr 26, 2010

I want to check if a MySQL db query will return an empty result - I first do this:

$query="SELECT * from <whatever" ;
$result=mysql_query($query) ;
$row=mysql_fetch_row($result) ;

Now how do I check if $row is empty or not? Will $row="" do the trick?

View 2 Replies View Related

Programming :: Get List Of Variables Of Particular Type ?

Jun 13, 2011

I have a C header file which have arrays of predefined(known) structure type. But i dont have names of arrays and their size. when i include that file and compile my application, i want to know the names and sizesof those arrays.

purpose of application is to get the content of those arrays and to explain it in descriptive words instead of hex numbers.ofcourse this can be done by file pointers and reading also with out header file inclusion, but as i am working in C, once compiled, those variables are in my address space in i include header file.

View 5 Replies View Related

Programming :: Passing Variables By Reference?

Mar 19, 2010

I was trying to make a code for passing variables by reference..here's the code:

#include<iostream>
using namespace std;
void fun(int& ,int& );
int main(){

[Code].....

invalid initialization of non-const reference of type 'int&' from a temporary of type 'int*'

View 9 Replies View Related

Programming :: PHP - How To Parse Data Into Variables

Apr 17, 2011

My php knowledge is very poor (only worked with strings so far), and I am faced which a task that is a real challenge for me: I have a variable, that contains data of different type, in this order: byte, byte, string, string, string, string, short, byte, byte, byte, byte, byte, byte, byte, string.

Strings are of variable length. How could this data be parsed into variables of the right type, and then all converted to strings? What are the functions to use? Strings are unicode ones, and they are delimited by "

View 4 Replies View Related

Programming :: PHP Sessions Variables Are Not Persistent

Jan 10, 2010

I just created a website in PHP and tested on my own webserver. All of my session variables worked great. Today I uploaded it to my commercial server host and it does not remember the session vars from one page to the next. Here is the session section of phpinfo().

Code:
session
Session Support enabled
Registered save handlers files user sqlite
Registered serializer handlers php php_binary wddx
DirectiveLocal ValueMaster Value
session.auto_startOffOff
session.bug_compat_42OnOn
session.bug_compat_warnOnOn
session.cache_expire180180
session.cache_limiternocachenocache
session.cookie_domainno valueno value
session.cookie_httponlyOffOff
session.cookie_lifetime00
session.cookie_path//
session.cookie_secureOffOff
session.entropy_fileno valueno value
session.entropy_length00
session.gc_divisor100100
session.gc_maxlifetime14401440
session.gc_probability11
session.hash_bits_per_character44
session.hash_function00
session.namePHPSESSIDPHPSESSID
session.referer_checkno valueno value
session.save_handlerfilesfiles
session.save_path/tmp/tmp
session.serialize_handlerphpphp
session.use_cookiesOnOn
session.use_only_cookiesOffOff
session.use_trans_sid00

You can see that session.save_path is set to /tmp, which is the default on the shared server. /tmp does exist in my document root directory.

View 3 Replies View Related

Programming :: Usage Of The Session Variables In Php

Jan 13, 2010

Im a fresher in PHP.Actually i wanted to know that whether there will be time delay while using session variables in PHP.By using some 10-20 session variables in my code will it affect the speed of the loading of the page.If so then can u suuggest any other method to pass the varaibles which will not slow down the speed?

View 4 Replies View Related

Programming :: Script Not Exporting Variables?

Jun 7, 2011

I have sles 10 . A user has a default shell of tcsh. I want to run a script which has to use ksh . In that script only some variables are exported, which will be used in subsequent scripts which are called inside it.

But the variables are not exported. I am unable to find whether its a conflict of shell or what ?? I tried with debug mode, it only displays the command but not execute anyone ..

View 14 Replies View Related

Programming :: Searching The Files Using Variables?

May 18, 2011

I have a file that contains 5 fields and anothen one with two I want to take the value from user and search file1 and if the value exists then write in file2 to the $2 to the line that $1=value

file 1
1:fsdfsd:g:33:fsdf
2:yytgdcf:a:3:sgd

[code]....

View 2 Replies View Related

Programming :: Shell - Substition Of Variables?

Mar 22, 2011

i have following code :

Code:
TMPDIR=`mktemp -d`
mkdir $TMPDIR/old/

[code]...

View 3 Replies View Related

Programming :: Best Way To Include Variables In String Using C

Feb 26, 2009

What's the best way to include variables in a string using C,i.e if i want to do the following query in C, how would i do that.How do i build the string variable up in C?

View 1 Replies View Related

Programming :: Using Environment Variables In Scripts?

Jun 19, 2010

Trying to mounts three cifs shares at boot up. I want to mount the shares under three different sub directories in the user's home directory:

share 1 mounted to /home/(insert username here)/movies
share 2 mounted to /home/(insert username here)/music
share 3 mounted to home/(insert username here)/software

I would like to use the environment variable HOME to dynamically build the mount point parameter. I've tried:

View 14 Replies View Related

Programming :: Variables With Spaces In Remote Ssh?

Nov 22, 2010

I'm writing something which takes user input (which may or may not contain spaces...) and then runs a command on a remote system via ssh. However the remote command does not work. I can't print the exact code so I'll just provide an equivelenat problem. This needs to work with filenames which do and do not contain spaces.

Code:
FILES=`ls`
echo "Specify a file"
echo "$FILES"
echo -n "File name: "
read $FILES
ssh root@127.0.0.1 "ls $FILES"

View 5 Replies View Related

Programming :: Using Grep / Variables In Bash Script

May 10, 2010

I'm trying to write a bash script and I'm having trouble with it.I have a list of DNS entires from a file called zoneExport.txt.Than I want to parse a log file to see if that DNS entry has been queried for. So I'm running a grep command and trying to save it into a variable. What I'm looking for is a variable ($varGrepQ) that has the number of matches for the grep query. I will then run this through an if statement and do some things from there..

But my problem right now is with this grep query. It keeps outputting '0' even when I know there are records in that file and when I run the same query on the command line I get the actual count. My thought is that the $record variable is not passing right.

View 4 Replies View Related

Programming :: Counting Variables In Bash Script

Nov 13, 2010

If I read in variables entered by the user, how can I check to make sure the correct number of variables were entered? For example, after reading in a data file and making it into an array, I have:echo "To check the data, enter the first element number, last element number and step size as x y z:"read x y z.It then goes on to start a loop, but what I would like now (before the loop) is a check to see if three variables have been entered, before the rest of the script continues.

I've tried specifying the variables as $1, $2 and $3, but if I echo $#, the value comes out as zero, so it's obviously not working.

View 9 Replies View Related

Programming :: Allowing Export To Take Numbers As Variables?

Jan 26, 2011

I'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really quick and easy.

export CS005DIR=/home/stud/0/043234/CS005

Now I get this error

CS005DIR=/home/stud/0/043234/CS005 No such file or directory.

This is because I've got numerical values within my variable.

Is there a way to allow numbers for variable names?

View 3 Replies View Related

Programming :: Use Environment Variables That Are Defined Outside Of The Script?

Feb 8, 2011

I am writing an expect script and I wish to use environment variables that are defined outside of the script.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved