Programming :: Passing A Variable At Compile Time - Send POSITION
Jan 14, 2010
I want pass a variable at compile time.
for example in x.c
int global_var = POSITION;
How can I send this POSITION at compile time. ie like # make POSITION=10 Is it possible?
View 5 Replies
ADVERTISEMENT
May 8, 2010
I have a file with around 1000 IP addresses in it and I need to be able to ssh into each one of them, run a single command, and then exit. I already know the ssh command I want to run and it looks like this:
Code:
shpass -p [password] ssh -p 10022 -o StrictHostKeyChecking=no root@[ip variable] 'reboot'
(I know shpass is not good to use and keys are the correct way but I don't have any other options in this scenario.) if these ip addresses were in a .csv file, by themselves with no other information, how would I create a script to do the above command to each ip until the end of the file?
View 8 Replies
View Related
Jan 14, 2009
I cannot for the life of me get this little (simple) script I wrote to work. Here is the entire script:
Code:
#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
SIZE=`echo 320x$HEIGHT`
[code]......
An input filename ($1) is fed into mediainfo, which by the use of grep and cut spits out a single number which is the aspect ratio. This is then divided by bc into 320, which gives the desired height dimension for the file that I want ffmpeg to create for me. Finally, ffmpeg runs using the calculated dimensions... Basically, it's the passing of the $ASPECT variable to bc that seems to fail. It looks like bc won't read the output from the mediainfo line... It always crashes out with:
Code:
(standard_in) 1: illegal character: ^M I've tried doing something even simpler like this to debug by just trying it to display the calculation on the screen:
Code:
#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
echo $HEIGHT
and it does the same, so it's definitely bc that won't accept the output from mediainfo.
View 4 Replies
View Related
Jan 9, 2014
I want to build on the code from /etc/apt/apt.conf.d/05etckeeper to work with Snapper, the new-in btrfs (et al) snapshot package.
Code: Select allDPkg::Pre-Invoke    { "if [ -x /usr/bin/etckeeper ]; then etckeeper pre-install; fi"; };
DPkg::Post-Invoke   { "if [ -x /usr/bin/etckeeper ]; then etckeeper post-install; fi"; };
The etckeeper code will work well as a template, but I need to pass a parameter between the pre- and post- instances. The parameter is obtained from the pre- invocation and passed to the post- invocation.I know that something similar to my quest is done with the 'pid' but how to do it in the 'standard' way. Happily there can't be multiple dpkg instances running concurrently (prevented by dpkg?) so I don't have to worry about that issue.
Q1. What is the 'standard' way of passing parameters about?
Code: Select allsnapper -c etc create -t pre -p   (which 'prints' the parameter (int) to pass to the following invocation)
snapper -c etc create -t post --pre-number <parameter> in place of the two etckeeper calls.
Q2. How do I pick up the 'printed' output of the 'pre' call? I think it's just a 'get' from the stream but perhaps I've missed something.?
View 2 Replies
View Related
Apr 12, 2010
I want to know is there some more efficient way of passing a pointer to a local variable as a parameter to a function in x86 asm? Right now I have to move the base pointer to a temp register, subtract from the register and pass that, like this (assuming a local var at esp-4):
Code:
mov eax, ebp
sub eax, 4
push eax
Is there a better way?
View 8 Replies
View Related
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
Jan 21, 2011
Say, i have an imaginary std library function, which I want to call.
Code:
void std_lib_func(ObjectType *param);
Now in my c++ program, I have a main() function, and I will like to call a customized function (which will in turn call the std lib function) from the main function, as below:
Code:
int main()
{
ObjectType *aobj;
customized_func(aobj);
}
[Code]...
I tried the below but get an error that the std lib function is expecting a ObjectType* param, not aobj. How should I work this out.
Code:
void customized_func(ObjectType aobj)
View 4 Replies
View Related
Aug 27, 2010
How can I to pass a perl variable into html input tag? For example, If a have got a cgi script:
Quote:
use CGI;
use DBI;
my $owner = $cgi->param('owner');
[code]....
How can I to pass $owner variable?
View 1 Replies
View Related
Sep 17, 2009
I'm trying to implement an assert function similar to:[url]
However, I'm having trouble with file existence testing when the file name has a space in it.
I have distilled the problem down to the following:
This code works as expected, printing 'yes' if '~/test file' exists, and no if not.
Code:
However, this code gives an error.
Code:
The error:
Code:
Which tells me that it is splitting ["~/test file"] into ["~/test] and [file"]. Why? Is there a way around this?
Note that if you simply use a file path without a space, both cases work perfectly. Is this a BASH bug possibly? I just can't understand why the first would work, but the second wouldn't.
View 8 Replies
View Related
Aug 21, 2010
This script works well but is there a better/shorter way of doing this?This creates dots to signify time passing. It will be used in a larger script.
Code:
D=".."
printf "$D
[code]...
View 6 Replies
View Related
Feb 13, 2009
I'm setting up a machine that's going to be used to test randomly connected tape drives one at a time, and as such, I'm writing the test routine using mt in a bash script, for user-friendliness. The problem is the block device name changes on occasion as tape drives are swapped out and busses are rescanned, so I can't "hard code" a block name into the script.
I know programs like lsscsi and hwinfo will give you block device names as part of their output, but I can't seem to grep anything in such a way as to have the final output be just the block name (ie /dev/st2, or optimally 'st2'), so that I can just have the script read said output, and drop it into the necessary variable.
View 2 Replies
View Related
Jul 3, 2011
"While ; do ; done" is very convenient for SH coding. However sometimes you may be annoyed by your computed variable within the "while do done" type loop. What to do how to pass it out of the loop to the outside of the bash code? A solution is to write it into the /tmp or on the disk... and to call it back after. - not elegant... really not... Anyone would know a trick another alternative that would look nicer?
Code:
# Count file total size
TOTAL_SIZE=0
LISTOFFILES=`cat "$HOME/.fvwmoscfg/fvwmburnerlist.lst"`
echo "$LISTOFFILES" | while read i ; do
SIZE=`du -bs $i | cut -f 1`
TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
echo "$TOTAL_SIZE" > "$HOME/.fvwmoscfg/fvwmburnerlisttotalsize.lst"
done
TOTAL_SIZE=`cat $HOME/.fvwmoscfg/fvwmburnerlisttotalsize.lst`
echo "The total size of all files and folders is : $TOTAL_SIZE"
View 8 Replies
View Related
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
Dec 8, 2010
Code:
#if defined(WIN32) || defined(WIN64)
#define WINDOWS
#endif
[code]....
what is the directive thats required to detect a linux system? i want to to be able to detect which platform im compiling on automatically.
View 5 Replies
View Related
Jan 8, 2011
I am new to bash scripting. I want to know whether i can pass one variable to another. For example $1 represent argument1. Now if i want to get the argument 1 like USER="1" now i want $ of $USER to execute $1 so what should i do..
View 2 Replies
View Related
Jul 24, 2010
How can I pass xml data from memory or a variable to xmllint that expects a file as input? Or does xmllint have the capabilities to read from stin or a variable?
View 4 Replies
View Related
Jan 15, 2011
It is known and well described in C++ standard ('C++ Standard - ANSI ISO IEC 14882 2003.pdf') that under certain circumstances types are promoted - for example, 'int' is promoted to 'double'.My design goal is to create wrappers around standard scalar types (like 'double', 'float', 'long', etc.) that would prevent such conversions/promotions, i.e. I want to create a really strictly typed C++ environment (like, say, OCaml).
However, the promotion is caught at runtime.Is there a way in C++ to catch/block such promotions/conversion at compile time ?
View 7 Replies
View Related
Jun 19, 2010
I have installed FC13 on my laptop and set it up as a development server. Here is my issue when passing variable from one page to the next it gets lost. My PHP includes work DB connect string works from the include.
View 1 Replies
View Related
Jan 21, 2011
In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save the output of time command in a variable. The format of the command is like "time ls -R /opt" Going further, the o/p of 'time' command is:
real 0m0.003s
user 0m0.004s
sys 0m0.000s
Here, in my script, I would like to use only middle line "user 0m0.004s" saved to the variable but unable to find out the way.
View 1 Replies
View Related
Oct 4, 2010
I'm installing ffmpeg with libavfilter using this guide but i can not get the movie filter to compile when passing --enable-avfilter-lavf to ffmpeg i'm using libavfilter r5935 and the test copy of ffmpeg.
View 3 Replies
View Related
May 16, 2010
I've written a bash script that extracts the audio out of a movie file and saves it out in separate .wav files using ffmpeg. Here is the key ffmpeg command:
Code:
ffmpeg -i $movie_file -vn -ss $start_time -t $duration ${file_name}_${counter}.wav
$start_time and $duration are floating point numbers that contain time information in the form of seconds and milliseconds (ss.xxx). It is important that I am able to control the time down to the millisecond.
My script works exactly as hoped on .avi files. My script needs to work on an existing archive of .mov files. when I try to use it on a .mov, the audio files created always have start times and durations that have been rounded up to the nearest half-second. This breaks up the audio in the wrong spots, and creates files that last too long and have too much extra audio. What can I do to make my ffmpeg command create .wav files from .mov files that properly recognize a specific number of milliseconds? Or, asked another way, how can I eliminate the rounding behavior?
View 4 Replies
View Related
Jan 27, 2011
I love docky but i have a really annoying problem.
Every time I login to my account, all my previously settings on Docky are gone. I move Docky to right, add some docklets and change some setings like Panel mode, etc.
But when I shutdown my computer, next time I login I see Docky in it's default setting again!
note: In the current session when I `killall docky` and `docky` again, it works fine and reload my previous settings. The problem happens on Logout/Login.
I run Ubuntu 10.04 on a Dell amd64 Laptop with 1.7x2 CPU and 2.3GB of RAM.
View 1 Replies
View Related
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
Apr 7, 2010
my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.
i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't
foo=+12.40
bar=${foo#+}
View 4 Replies
View Related
Mar 9, 2011
I am trying to make a simple alias for find command that acceps a variable.
alias myfind="find $@ -type d -exec chmod 777 -fv {} ;"
this alias tells me that "find:paths must precede expression"
View 6 Replies
View Related
Apr 25, 2011
how I can search within a variable and assign the results to a new variable. I'll use the following as an example -
cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`
with the echo command I get the following output assigned to list -
A
C
C
What I'd like to get for output is -
Audi
Cadillac
Chevy
how I could do this regardless of upper/lower case letters?
View 5 Replies
View Related
Oct 6, 2010
I can't figure out the exact sed to make this work. I've installed CentOS and am trying to pass variables to a network-config file.
variables:
$ipAddress
$netmask
[code]...
View 1 Replies
View Related
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
Apr 22, 2011
I am trying to check if the 9th character in a file on each line is a v and if so, then print the first word. I've tried a number of variations and am stuck !If it's possible to also check if character position 1 begins with a s in the same awk, that would make it cleaner instead of using egrep.
egrep '^s' file | nawk '{virtual=substr($0,9,1); if ($virtual=="v") {printf "%s", $1}}'
nawk: illegal field $(e)
input record number 1
source line number 1
View 13 Replies
View Related
Dec 13, 2010
i need to overwrite each line of the file starting from a specific position to the end of the line
example:
ATOM 981 N PRO B 159 55.662 7 1 1.47 0.75
i need to write " 1.00 0.00 " starting from 20position
i tried
sed -i 's/^(.{20})*/ 1.00 0.00 ' filename
but it doesnt work :"(
View 5 Replies
View Related