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


ADVERTISEMENT

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 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 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 :: 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 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

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 :: 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 :: 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

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

View 8 Replies View Related

CentOS 5 :: Pass Shell As Command Line Argument When I Ssh To An Account

Jan 25, 2011

I want to have a choice or more preferable pass shell as command line argument when I ssh to an linux account.i.e. If John logs in to account "zzz" on server "abc", by default definition of account "zzz" n server "abc" he get csh.But Sally desires that when she logs in to account "zzz" on server "abc", she needs the login shell to be ksh,and Rick wants bash when he logs in to account "zzz" on server "abc".What is the most non-intrusive / easiest way to achieve this? Each user can set their preference on ssh command line or create a simple alias by each shell, but not sure how to do this.

View 6 Replies View Related

Programming :: Can Awk Take A Shell Variable

Jul 23, 2010

I have been searching most of today and am stuck on getting a variable into an awk portion of my bash script. I have this working:

Code:

#!/bin/sh
SRC=/var/log/mail.log
DEST=/var/www/output/myFile.txt
VAR=userName@myDomain.tld

[code]....

Can awk take a shell variable? Or do I have to do something completely different?

View 11 Replies View Related

Programming :: Writing Unix Shell Script To Pass File Name/path/creation Date?

Oct 7, 2009

I'm new to UNIX scripting; I�m stuck with the following I have an Oracle SQL script that takes three parameters

1- File Name
2- File Path
3- File creation date

Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need is a UNIX script that can do the following

Loop through Directory "/home/applmgr/snktmp"
Picks only files
Pass the file name to parameter &1

[code]....

Is the above possible? I already knows how to call the Oracle Script from UNIX Im only stuck on writing the UNIX part where it List the files attribute(name,path,date) and store them to parameters ,Looping until the last file in the directory If the above is not possible,then how can I create the below from the command line

Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate

View 4 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 :: Debugging Shell Script With A Variable Expansion?

Jan 20, 2011

What I am trying to accomplish is a way to read only the lines that have been added to the file mylog0 since the last time the script looped (5 seconds). I am open to new suggestions too, I have been stuck on this little script for a few hours already.

Code: #!/bin/bash
i=0
firstline=0

[code]...

View 2 Replies View Related

Programming :: Grep - Include Glob With Shell Variable

Nov 10, 2010

Code:
grep -r $SEARCHDIR --include="day_$YYYY-$MM-*" -h -o -e PATTERN

The above command does exactly what I want: limit the search of files in $SEARCHDIR to those specified by --include.

I use double quotes rather than single quotes because of the shell variables. I would have thought this would cause the shell to expand the "*" but this doesn't seem to be the case.

View 1 Replies View Related

Programming :: Loops In Bash Shell Or Variable Math?

Oct 28, 2010

I am trying to map the coordinates of a grid.

Code:

R=7 # number of rows (lines)
C=6 # number of columns
X=200 # initial horizontal location
Y=100 # initial vertical location

[code]....

View 4 Replies View Related

Programming :: Shell To Remove Line Matched With Variable?

Jul 25, 2011

I'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file

Philip S:Odds:45:343
Mike Junior:Odds:3:56

I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.

View 4 Replies View Related

Programming :: Pass Carriage Return To Command Through Script

Feb 18, 2011

How can I pass carriage return to a command in the shell script. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (i.e., press Enter button) to this command.

View 2 Replies View Related

Programming :: Checking Shell Script Variable Contain Numeric Data

Mar 28, 2009

I need to check whether a shell script variable contains non-zero numeric data to proceed. The variable should contain numeric values, but may in fact contain zeroes, blank space or nothing. So far, I have tried various combinations of:

Code:
if test $variable
then
if test $variable -gt 0
then
echo "good data exists"
else "no good data exists"
fi
fi
It partially works, but I get either "too many arguments" or "integer expression expected".

View 2 Replies View Related

Programming :: Calling Command From History Using Variable Like !$command?

Nov 19, 2008

suppose i store the history number of a command say :

1004 cat file

Then now i want to run it like : !1004 but by using a variable.

command=1004
!$command

i am getting errors like :

command=1004command

View 2 Replies View Related

Programming :: Write Scripts To Pass 2 Different Variables To Find Command

Aug 18, 2010

i am trying to write scripts to pass 2 different variables to find command.

find . -name $var1 -exec grep -H $var2
find . -name CDR_2010-07-21 -exec grep -H 9892614477 {} ;

1st variable CDR_2010-07-21(passed by var1) is the file name inside which i am trying to search string 9892614477(passed by var2). i have tried following script

[code]...

View 9 Replies View Related

Programming :: Udev Rules - Pass ATTRS{*} Values To The RUN Command?

Sep 24, 2010

I'm modifying a working udev rule which runs a script that mounts a USB HDD and synchronises files to it.The USB HDDs have been troublesome, losing many files and even losing file systems a couple of timesTo investigate,I want to log the USB HDD product name and serial number so would like to pass ATTRS{product} and ATTRS{serial} values to the script.This may not be possible; I cannot see anything about how to do it in either the udev man page nor Daniel Drake's "Writing udev rules" Version 0.74 but it seems such an obvious thing to want to do, I'm wondering if I've overlooked something.

View 8 Replies View Related

Programming :: Using Variable In A Command?

Apr 14, 2011

i'm trying to execute a shell script, i'm trying to use the values in an array for use in a sed command:

sed -n '/Sales ID: ${array[$i]}/,/Totals:/p'

that command creates empty files. so my guess is that its not recognizing the array as an array but as text?
how would i be able to utilize the array in the command? i got it, didnt think that if i doubled up the single quotes that it would work, but this worked:

sed -n '/Sales ID: '${array[$i]'}/,/Totals:/p'

View 4 Replies View Related

Programming :: Store A Command In A Variable?

Jan 28, 2010

Code:

ls Again the command can be stored in a variable and then executed. Like

Code:

var=ls
&var

The above two codes are the same. The problem occurs when we try to pipeline it. Consider the following problem:

Code:

ls | grep *

works fine...but when we try to store it in a variable and run the command there is an error.

Code:

var="ls|grep *"
$var

how to store this kind of commands in a variable?

View 11 Replies View Related

Programming :: Show The Output Of Shell Command Into A Textbox, Ex Ps -efc Command?

Oct 20, 2010

I am using gtk to program GUI. How can I show the output of shell command into a textbox, ex ps -efc command ?

View 3 Replies View Related

Programming :: Change Variable In Case Command?

Aug 7, 2010

I want to display 4 options using the case command and refresh the screen when options 1 and 2 are chosen (no changes to the options and you get asked again to chose option), but give a message for option 3 and exit on option 4. I set this up with the script below, but choosing option 1 works and choosing option 2 exits the script.

Code:

#!/bin/bash
#testing options
Option="0"

[code]....

View 7 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

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 :: Put A Variable In The $PS1 Prompt That Will Change Each Time A Command Is Run?

Feb 11, 2011

I would like to put a variable in the $PS1 prompt that will change each time a command is run. I want the color of the $PS1 prompt to change each time a command is run.I know that I can do this:

Code:
PS1="h@w # "
## "#" is changes every time a command is run

[code]....

View 9 Replies View Related







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