General :: Pass A Variable To A Function That Already Being Escaped?

Jul 28, 2010

What i want to do is create multiple informix sql statements & later run them via a bash script.

Here is what i have so far (this works) but is meant to be run from a cron job so it only does one day at a time:

echo "
update hst`date --date='yesterday' +%m%d%y`
set x = 'GARP'
where y in ('CRE', 'LAC', 'SRL', 'JAG', 'JNM', 'BIM')
and appl = '';

[Code].....

The problem here is it doesnt want to read the variable $x correctly so the statement fails.

View 1 Replies


ADVERTISEMENT

General :: Pass All Arguments To A Function?

Jul 6, 2010

I've got a sticky little problem with a bash script. Please consider the following code:

Code:
#! /bin/bash
processArgs() {
echo "Count = $#"
while [[ $# -ne 0 ]]; do
echo $1
shift
done
}

processArgs $* If I call this script with Code: ./script first second third it'll print each of the argument on a new line - exactly what I would expect. However if I call it with

Code: ./script "Single Argument" "Second-Argument" it splits the first argument in two using the space as a delimitor. The problem appears to be the call to processArgs, where $* doesn't honour the quotes around the variables sent to the script.

View 4 Replies View Related

General :: Pass A Variable From One Script To Another?

Nov 22, 2009

I want to pass a variable from one script to another, I have a feeling it's extremely simple.

I looked at exporting, but apparently that clogs up the shell, so I don't want to go down that route. Any suggestions?

View 2 Replies View Related

General :: Anything Syntactically To Pass Variable To Smbclient?

Feb 23, 2010

I am trying to pass a variable to smbclient (OS X), but the variable is recognized only as its strict text.

Is there anything syntactically I have to do pass a variable created in the shell (bash) to smbclient (or perhaps any other interactive app)? I've seen references to variables as $[variable] or ${variable} but I've not been able to figure out what works.

View 5 Replies View Related

General :: Recalculate Variable For Each Pass Of An Until Loop?

Feb 11, 2010

I am trying to write a script that will find any user on the server running more than one instance of the epiphany web browser process, then kill all their epiphany pids. (This is necessary sometimes to cure lockups, and repeat processes are the telltale sign in this case). I have tried implementing the until loop:

Code:
USER=`ps aux | grep epiphany | grep -v grep | sort | uniq -d -w 5 | awk '{print $1}'`
until [[ "$USER" == "" ]]
do
ps aux | grep epiphany | grep -v grep | grep $USER | awk '{print $2}' | sudo xargs kill
done

Unfortunately, the script only calculates the USER variable once at the beginning of the script. Fair enough, that's how it's written. My question is, how would I get the USER variable to update for each pass of the until loop so that it could cure multiple users of this ailment if necessary? That is, calculate $USER, kill their epiphany pids, repeat those two steps until the $USER variable comes up blank, then exit.

View 5 Replies View Related

General :: Executing Binaries - Pass The Hostname As A Variable Or Read From A File?

May 2, 2010

I am looking for a clue in shell or ant script, where I excecute a binay file on linux. For example ./myfile.bin which ask me few questions.

./myfile.bin ...........................100%

I would like to automate this process where I want to pass the hostname as a variable or read from a file is it possible? If yes any sample`s on this. I can do if this was a shell script ($1) but not sure when its binary.

View 8 Replies View Related

General :: Bash Catching The Function Returning Value Into A Variable?

Mar 17, 2010

i am dealing with this problemI have a function

function Une {
...
return $some_variable

[code]...

View 6 Replies View Related

Ubuntu Security :: Included The Output Of Both "un-escaped" And "escaped" Input To Show The Importance?

Feb 14, 2010

quite some time back, when I was learning about MySQL injections it has sorta been drilled into me to use mysql_real_escape_string when dealing with input from users.[URL]..I'm running a standard LAMP installation, with no alterations to the defaults.

On the site in question, I do have this all set up, however, as part of a tutorial series on FULLTEXT, I've included the output of both "un-escaped" and "escaped" input, to show the importance.

[Code]...

View 2 Replies View Related

Programming :: Pass Variable Between Scripts?

Mar 9, 2011

I need to pass variable from sc1.sh to sc2.sh and update the value of the passed variable in sc2.sh and then return the updated value of the variable from sc2.sh to sc1.sh.

View 7 Replies View Related

Programming :: Pass Arguments To A Function Using A Loop

Mar 1, 2010

I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like

Code:
for(i=0;i<NUM;i++)
{
push_arg(args[i]);
}
call_function(func);
?

Of course, i could just use asm code for this, but is there a portable way of doing so?

P.S. i mean C language.

View 2 Replies View Related

Ubuntu :: C++ - Can't Pass System Output To Variable ?

Sep 8, 2010

I have a line that looks something like this:

Code:

How do i put its output in a variable?

View 9 Replies View Related

Server :: Get Variable From Bash From Mysql Or Pass From Php?

Apr 26, 2010

I am not parsing on a webserver so is it possible to have both

#! /usr/bin/php &
#!/bin/bash

in the same script? Alternatively, I have a current bash script that I need to get some variables from mysql and not sure how to get mysql results in bash:

Quote:

mysql -h server.net -u username1 -paaa -e "USE squid; SELECT email, usern FROM TABLE WHERE blah blah;"
emailadd="resultfrom above"
usern="resultfromabove"

View 11 Replies View Related

Programming :: Pass A Path As A String To A Variable?

Apr 17, 2009

I'm trying to pass a path as a string to an array, but its evaluating it as a command instead. I want to take the literal string "/mnt/accounts/user/temp/*.jpg" and assign it to an array{1}, but when i echo the array variable, it displays it as

pic1.jpg
pic2.jpg
pic3.jpg

[code]....

I just want it to be the actual text "/mnt/accounts/user/temp/*.jpg" which i will be combining with other text to create a longer path elsewhere in the code.

View 5 Replies View Related

Programming :: How To Pass Sed Address By Shell Variable

Aug 2, 2011

Code...

I am somewhat confident that there is a neater way.

Question: Does anybody know the answer?

View 3 Replies View Related

Programming :: Pass A Shell Variable To An AWK Command?

Dec 23, 2010

I have the following code :

Code:
E_BADARGS=65
if [ $# -ne 2 ] ; then

[code]...

View 1 Replies View Related

Programming :: Pass Variable From One Shell Script Into Another

Oct 2, 2009

I have some messy code that I wrote a while back and I am trying to organize it. The program opens xpaint and uses xwit and xte to draw packman and so on. I want to split it all up I am going to add more to it. Basically like i would want drawing packman in one function i guess you could call it and then coloring him or the background in another

<code>
#!/bin/bash
pkill xpaint
res=`xwininfo -root | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`
Xoriginal=`echo $res | cut -d 'x' -f 1`
Yoriginal=`echo $res | cut -d 'x' -f 2`

X=`echo "($Xoriginal/2)-400" | bc `
Y=`echo "$Yoriginal/2" | bc `
#t=$(($Y/2))
bob=`echo "$Y/2" |bc `
echo $X
echo $Y

/usr/bin/xpaint -size "$Xoriginal"x"$Yoriginal" -popped &
sleep 4
paintersMom=`xwit -all -print | grep XP | cut -d ":" -f 1`
canvasWin=`xwit -all -print | grep Untitled | cut -d ":" -f 1`
#toolres=`xwininfo -id $paintersmom | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`
#canres=`xwininfo -id $canvasWin | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`

#echo $paintersMom
xwit -id $paintersMom -move 0 0
xwit -id $canvasWin -move 0 0
xwit -root -warp "$X" "$Y"
sleep 4
for((i=45; i < 315; i++))
do
xte 'mousedown 1'
ang=`./deg2rad $i`

movex=`echo "$X+$bob*c($ang)" | bc -l`
movey=`echo "$Y+$bob*s($ang)" | bc -l`
xwit -root -warp "$movex" "$movey"
done
xwit -root -warp "$X" "$Y"
xte 'mouseup 1'

#xwit -id $paintersMom -focus -raise
#sleep 1
#xwit -id $paintersMom -warp 30 390 #// fill in command on tool bar
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -id $canvasWin -warp 221 40 #// color selection
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -id $canvasWin -warp "$(($X-150))" "$Y" #//location on pac man
#sleep 1
#xte 'mouseclick 1'
#sleep 1

#xwit -id $canvasWin -warp 62 44 #// selecting color black
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -root -warp 62 120 #// selecting back to canvas
#sleep 1
#xte 'mouseclick 1' #// color canvas black
#sleep 1
#xwit -id $paintersMom -focus -raise
#xwit -id $paintersMom -warp 27 108 #//click back to pencil
#sleep 1
#xte 'mouseclick 1'
#sleep 1
</code>

Here for example $paintersmom is would be in the drawing of pacman but I would also want to use it when I colored him in.. but I would want both processes in a different shell script.

View 15 Replies View Related

Programming :: Pass _server Variable To Html?

Dec 20, 2010

This is a section on a php file running within a a Joomla module. I have the following code:

Code:
<?php echo '</div>'; ?>
<html>

[code]....

View 2 Replies View Related

Programming :: Pass A Char* Array As A Function Paramter In C++?

Jan 27, 2011

I have the following char* array

Code:
char* chrarray[] = {"Hello","LinuxQuestions"};
and I need to pass it into a function, how should I define my function in the header file?

[code]....

View 3 Replies View Related

Programming :: Pass An Expect Command Result Into A Variable And Then Use It Again?

May 4, 2010

I'm trying to create a program that would locate the oldest file of a certain type on a server. Here's the commands:

OLDEST_PATH=`find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1`
OLDEST_FILE=`find -L $OLDEST_PATH | grep .mp3 | sort -f | head -1`
ls -al $OLDEST_FILE

I'm writing this all in expect but I'm having problems. The main problem I have is whenever I try to run the first command, I can't seem to isolate the result of the OLDEST_PATH so that the 2nd command will work. There always seems to be a newline in the variable and the result is only "find -L" command running and it bypasses the variable. If I can just figure out how to get the 1st and 2nd command to work, then I can figure out the 3rd. Here's some code:

Code:
send "find -L / -depth -maxdepth 6 -mindepth 6 -type d | sort -f | head -1
"
sleep 20
expect -re "(.*)

[Code]....

I know there is a better way to write this. I've tried multiple ways and this just happens to be the last way I've tried it. If you try running this, you'll notice that there is still carriage returns after the result of OLDEST_PATH and it prevents the 2nd "find" command from working properly.

View 2 Replies View Related

Programming :: Python : Pass Output Of System Commands To Variable?

Jan 25, 2011

I'm trying to write a python script that will use the current user's name when interacting. Ex: when started, it should say "hello daweefolk" when I am logged in.
I've tried
Code:
username=os.system("echo $USER")
but the variable remains empty.
What is the correct code?

View 1 Replies View Related

General :: Why Are 0 's Escaped In Hexdump

May 10, 2011

I was looking at this file that was padded with 0's in hexdump. I noticed the 0's were escaped so they would be literal 0's. Why is this?

View 1 Replies View Related

Programming :: Bash: Give A Variable The Value Of A Function?

Aug 8, 2010

I was wondering if possible in bash for a variable to take the value of a function, I mean the function returns a value and a variable will take it. example:

[Code]....

View 3 Replies View Related

Programming :: C++ Using Private Variable In Public Function?

Feb 6, 2011

I have a class in which a have declared a private variable "time". In one of the public functions, I am returning the value of "time" (either directly by using "return time;" or by something similar to "x=time; return x;" but I keep getting a compiling error saying that "time" is not declared in this scope.

View 3 Replies View Related

Programming :: Function Pointers With Variable Arguments

Jul 14, 2011

I need to call functions that match an input string (if input str = "func1", call func1), so I have this:

Code:
#include <stdio.h>
#include <string.h>
void function_a(void) { printf("Function A
"); }

[Code].....

In the above example, the functions take no input arguments. Can they take a different number of arguments, for example, function_a(int), function_c(int, int), function_e(int, char, int)? How can I do that?

View 3 Replies View Related

Programming :: Does Declaring Variable Inside A Function Give An Extra Overhead On An Application

May 14, 2011

Does declaring variable inside a function give an extra overhead on an application? Would it be better to declare the variable globally and just reuse it? Example

Code:

#include <blah>
char mybuffer[2048];
int main()

[code]....

The only difference is the declaration of my variable. Since myfunction() will be called many times will it add an additional overhead if it will create mybuffer[2048] over and over?

View 5 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

General :: Write Script To Use Function And Still Keep Function Active?

Feb 21, 2010

the function terminates if no key is pressed for 10 consecutive seconds. I tried using the -t option as suggested in some forums, but my version of showkey doesn't have the option of changing the timeout. The options I get are:

-h --helpdisplay this help text
-a --asciidisplay the decimal/octal/hex values of the keys
-s --scancodesdisplay only the raw scan-codes
-k --keycodesdisplay only the interpreted keycodes (default).

Is it possible to write a script to use this function and still keep the function active until an interrupt is recieved?

View 6 Replies View Related

General :: Assign Local Variable Values To Global Variable?

Feb 17, 2011

how to assign a local variable value to a global variable....

View 2 Replies View Related

General :: Create An Environment Variable With The PRINTER Variable?

Apr 16, 2011

I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)

View 3 Replies View Related

Programming :: Md5sum Bash Script With Escaped Characters?

Apr 15, 2010

I created a file holding all the md5 values of my files to find duplicates as follows: find /mnt -type f -print0 | xargs -0 md5sum >> ~/home.md5

I then tried to find duplicates and do ls -l on the result in such way: cat ~/home.md5 | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{print $2}' | head -n 10 > ~/top10.md5

Now I attempted to do an ls -l on the files using the command: for i in `cat ~/top10.md5`;do grep $i ~/home.md5 | while read checksum path; do echo "`echo $(printf '%q' "${path}")`" | xargs ls -l; done; done

This works well on most files, however it does not work when filenames have special letters in them that gets escaped such letters with accent etc. These become for examle 303.

Are there any ways I can use the escaped 303 strings with path names, or any better way I can do this?

View 2 Replies View Related







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