General :: Assigning Query Result Into A Variable/file?

May 25, 2011

I am connecting to MySQL DataBase using shellscript and writing a select statement like select attachmentid from attachments where pageid=10175 I want to store the output of the select statement into a shellvariable or a file. How can i do it using shellscript.

View 4 Replies


ADVERTISEMENT

General :: Sed: Assigning Its Output To A Variable?

Feb 3, 2011

Kernel 2.6.21.5, GNU/Linux (Slackware 12.0).In this script,

Code:
semoi@darkstar:~$ cat rename4.sh
#!/bin/bash
INPUT="k3b_audio_0_04"

[code]...

View 3 Replies View Related

General :: Assigning Value To A Variable In Shell Script?

Nov 22, 2010

Why doesn't "var1=`echo $var2 | grep pattern`" work ?

View 8 Replies View Related

General :: Store Result Of Wc -l Command In Variable?

Apr 19, 2011

I want to store the result of wc -l as a variable so I can use it later in my script...so far unsuccessfully.

I have tried this:

set `echo awk '{ print $1, $6}' | wc -l` | echo $1

but it is far from working.

View 11 Replies View Related

General :: Use Result To Be Saved In Variable - Which Type Would It Be In Script

Feb 5, 2011

If I want to use that result to be saved in a variable, which type would it be in script? For clearing: let variable x and destination path is y/z

in prog.sh:
x=du -hb /y/z
echo $x

Q1: What type of x?

Q2: What option instead of -hb to presedent the size in kib?

View 11 Replies View Related

Programming :: PHP / MySQL Statement - Query Result

Jan 29, 2011

It is under PHP/MySQL
$queryresult = $conn->query("INSERT INTO normalrequests VALUES($finalkey, 1234, 5678, FALSE)");
It is connected to the database successfully but I feel there is something wrong with the statement up there.

View 6 Replies View Related

Programming :: Change A Mysql Query Result Prior To Display?

Oct 17, 2010

I am not sure if this is possible. I have IP's stored in a mysql database. When I query the database, it returns the IP. I would like to replace the IP with something else prior to displaying the results. Is it possible even though I have not stored it in the database?

I have the following in a while loop (mysql_fetch_array).

Code:
<td align="left">' . $row[IP] . '</td>

Instead of displaying $row[IP] from the database, I would like it to display something else which I define in the PHP code but based on the IP.

ie. aaa.bbb.ccc.ddd = hostnameABC

View 4 Replies View Related

Programming :: Assigning Variable Is Messing Up?

Nov 5, 2010

I am trying to run this and was into issues

function() {
node=echo "10.11.12.13" | awk '{split ($0, a, "."); print a[1]}'
}

[code]....

View 1 Replies View Related

General :: Assigning "find" Operation Output To A Variable?

Jan 7, 2011

I am assigning "find" operation output to a variable. I also need to have error info / stderr if nothing is found in the same variable itself.

e.g.

a=`find . -name "hello.txt" -type f`

I do not want any temp files to be in between infact, redirection.

View 5 Replies View Related

Programming :: Assigning A Variable For Later Use In Shell Script ?

May 4, 2010

Using things like awk/sed, but have managed to cobble together what I needed so far without a problem. The only thing I'm struggling with is to assign the content of a particular line as a variable, and then to use it again throughout the file.

For example, if what I want is the first line of the file to become the variable "from1", and then to replace the word "Subject" in the file with the string "Message from [from1]". What I thought would work

I tried a few diff combinations but nothing seems to work. All I get is the terminal hanging indefinitely.

View 3 Replies View Related

Programming :: Assigning Bash Variable With The System Command In Awk?

Mar 1, 2011

I am having all sorts of trouble trying to assign a variable within an awk script with the system command. I know there is a lot of ways around this problem, but for efficiency reasons, I would like to, within my awk script, do something like

system(x=3)

or

system(x=NR)

and, latter on the shell script which calls the awk script, use the variable $x. But nothing is passed to x. I have already tried things like

command = "x=3"
system(command)

and also used a pipeline within the system to pipe it to /bin/sh In fact tried a lot of stuff like that, using $(( )) etc etc etc I can create directories e write to files (yes, i could write to a file and read from there, but I dont think it is efficient, plus I am puzzled).

View 7 Replies View Related

Programming :: Assigning Structure Object's Variable Outside Main() Gives Parse Error

Sep 2, 2010

Kindly take a look at the code below :

Code:
#include <stdio.h>
struct test
{
int i;
int j;

[Code]....

why i am getting this error. I know the error is occuring because i have assigned values to obj.i and obj.j outside main(). But i want to know why do that result in an error. From my part i have created an object 'obj' of stucture 'test' and assigned values to its variables.

View 7 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 :: Passing Variable To Oracle Query With PHP

Jul 11, 2011

I'm having some trouble this morning to send a SQL query to our Oracle DB server in PHP. When I try to pass my value "OF/110246801A01" as variable it tell's me "Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number"

PHP Code:
$ociO ='OF/110246801A01';
$selectAllFieldsFromOf=oci_parse($conn,"SELECT*FROMMFGOPEWHEREMFGNUM_0LIKE':ociOf' ");
oci_bind_by_name($selectAllFieldsFromOf,":ociOf",$ociOf,15);
$resultQuery =oci_execute($selectAllFieldsFromOf);
if(!$resultQuery){
$e = oci_error($selectAllFieldsFromOf);
return trigger_error(htmlentities($e['message'],ENT_QUOTES),E_USER_ERROR);
[Code]....

View 1 Replies View Related

Server :: Script Query - Create A Folder With An Environment Variable?

May 18, 2010

I am busy learning shell scripting, and I managed to get my first few right, but now I am trying to do something that I know how to do in Windows, but not in Linux. Basically, during a file copy, I want to create a new date for each folder on a daily basis to copy backups into.so, in windows the syntax would be "xcopy %systemroot%ackupslah.blah \servernameackups\%date%"in linux I am running a "cp blah.gz /mount/blah" I want to create a folder with the date based on the current date.anyone know how to get the same right in shell script?

View 10 Replies View Related

General :: Assigning New Creation File Time On Tar Extraction?

Nov 19, 2010

How I can tell tar to assign a new creation date to extracted files? Let's say I have an archive filled with old files of varying ages. Upon extraction I want all files to have the same time stamp (that of the time of the extraction).

View 1 Replies View Related

General :: Script To Access Sqlplus And Use The Output To Replace The Result In Another File?

Aug 30, 2010

I am trying to write a script to access sqlplus and use the output to replace the result in another file. But I am having some issues with it (This script is just a test script and I am just trying to print the updated value.

#!/bin/bash
I am not able to post the sqlplus connection, but it works.
bb=$a

[code]....

View 2 Replies View Related

General :: Write A Script To Access Sqlplus And Use The Output To Replace The Result In Another File?

Aug 30, 2010

I am trying to write a script to access sqlplus and use the output to replace the result in another file. But I am having some issues with it (This script is just a test script and I am just trying to print the updated value.

#!/bin/bash
a=`echo exit|sqlplus -S -L xxx/xxx@xxx @test.sql`
bb=$a

[code].....

View 5 Replies View Related

General :: Rpm Spec File Conflicts Syntax Query - Not Keeping The Package Name

Mar 9, 2011

I have inherited our Linux packaging and as the number of versions increase, the number of conflicts is starting to get a bit unmanageable. I believe the easiest way would have been to keep the package names the same and just change the release in the spec file but unfortunately I am past that as a lot of these packages are rolled out to our estate. (I am told there were reasons for not keeping the package name the same and incrementing the version/release)

Is it possible to wildcard conflicts so I don't need to keep adding as new versions are created. For example, instead of using all the conflicts below, have something along the lines of AAtest45* <= 1.4 & BBtest45* <= 1.4 Meaning that all I would need to do was change this to 1.5 at the next release (the packages below version matched the release in the spec file)

[Code]....

View 2 Replies View Related

Software :: Grep Query To List 1 Line (which Is Fixed) And The Next Line After It (variable Text)

Jan 20, 2011

How can I list the following with grep. I want to extract 2 lines fron a text file The fixed known part if it exists will static text and the text line after it will change.

A sample file
.
.
textline1

[code]....

If the fixed part does Not exist how can I return error code 1

View 3 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 Replies View Related

Programming :: KSh Script - Assigning A File Path ?

Jul 25, 2011

I am assigning a file path to a variable like

$1 means it should accept some file name from cmd prompt but in my case its not working.

View 1 Replies View Related

Ubuntu Installation :: Assigning / Tmp And To Mount On File System / Not In Root

Nov 26, 2010

I am pondering a reinstall of a freshly installed Ubuntu; I may or may not take that drastic step.However, I have partitioned my drive to include a 16-GB partition labelled "Ubuntu-tmp", in my case /dev/sda7, with the intent of mounting that file system as /tmp. Depending on how I decide to go about the reinstall I need an answer to these questions:If I reinstall: Is it possible to designate /dev/sda7 to mount as /tmp during the installation process?If I cannot designate the mounts at install time, or if I opt not to reinstall: I can't really empty the /tmp directory in the root in order to properly use it as a mount point for [the file system on] /dev/sda7; many files in there are still in use by running processes. So how can I clear the /-mounted /tmp directory and assign it to /dev/sda7?

I have attached a screen shot of gparted to illustrate my layout scheme.The gparted manual suggests I select the partition, click [Partition]->[Mount]. Of course, my gparted drops a menu with [Mount] is absent and an [Unmount] option is greyed out.This raises a question of how I am going to mount /users and /var in their intended file systems (/dev/sda8 and /dev/sda9, respectively), because the [partition] menu looks the same for these partitions as well.

View 5 Replies View Related

General :: Using Variable To Run An Executable File?

May 27, 2010

I have an executanle file in a directory (say /home/mahmood/test/do-sample) and in a bash file I want to run it:

Code:
#!/bin/bash
M_VARIABLE = $HOME/test

[code]...

View 3 Replies View Related

General :: Sorting A File With A Variable Name?

Jun 27, 2011

I am trying to sort a file, so I can compare it to another file later. I am storing the file name in a variable called curMo. I then call sort $curMo and it hangs for a very long time and I have to quit the process. why this is not working or how to make it work?

Here is part of my code:

#sort this file for this Location
sort -u $curMo -o $curMo.sorted

View 1 Replies View Related

Ubuntu Servers :: What IP Address To Enter In Config File When Assigning A Static IP

Apr 6, 2010

How do I decide what IP address to enter in my config file when assigning a static IP. All of the instructions I can find say something like "of course you should modify the file according to your own settings." Should I just use the gateway and IP that returns from "iwconfig" and "route -nee"?

View 5 Replies View Related

General :: Reading File Into Variable In Bash?

Mar 21, 2011

I know that cat can output the file, but how do you store that output in a variable to process:

Code:

CONTENT=cat file.txt

This doesn't seem to work?

View 3 Replies View Related

General :: Parsing Delimited File And Variable Scripting?

Sep 23, 2010

I did some searches and after a few hours was able to get what I needed. What I didn't find was a fully encompased means of what I'm used to in the windows world in working with delimted files. Hopefully this is helpful to others and if there is something better or leaner way, even better.We have an issue where managing printers, just viewing on RHEL w/ sys-conf-prtr we lose any number of, up to ~30 printers from lpadmin. Rather than stare and compare to find the missing ones, I wanted to make an intuitive script. This is what I came up with.

Code:
#!/bin/sh
while IFS="," read Prntr IP; do

[code]...

View 3 Replies View Related

General :: Pull String From A File Into A Variable Using Bash

Aug 6, 2011

I have a file (.tmpfile) and inside it is a string which i only know part of, the rest being a random group of characters... I would like to know how to pull the whole string out of the file and into a variable.

View 13 Replies View Related







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