Programming :: If Statements With Decimal Places - Compare It To A Predefined Value
Aug 11, 2010
I'm writing an if statement where a variable is a number such as 14.05 (this is actually a temperature) and I want to compare it to a predefined value, sample code below:
Code:
I have all sorts of errors regardless of how I do this (double quotes, square brackets). The best idea I've had is stripping off the decimal place so it's a 4 digit number (e.g warning=1503 and DEV_TMP=1405) however this seems a little unnescessary and I'm sure there's an easier way of achieving the same thing.
View 11 Replies
ADVERTISEMENT
Jun 9, 2010
I am using C++ with SQLite db in a program that will read read a sub set of records, compare records and write different records to another database. I have a SQLite book, but it only shows examples for the C API. Anyone have code samples in C++ for the following:
Open database
Close
Select *
Read
Write
Or, just show me how to execute a SQL statement with C++ and I can then figure out the various SQL statements I need.
View 5 Replies
View Related
Mar 31, 2011
snappy title to grab attention. maybe not stupid, but bleeding difficult to use, talk about a non-obvious, non-intuitive interface; I want to enter a hex value, and have the calculator convert that to decimal. So, I use the pull-down, choose 'hexadecimal', enter the hex value, then change the pull down to 'decimal', expecting to see the decimal (base 10) value. What do I see? The display just adds the hexadecimal base to the end of the hex value I just wrote! Where's my decimal (base 10) number damn it? I can't for the life of me work it out.
View 4 Replies
View Related
Aug 9, 2009
I have a script im having some problems with, what I need is to have the system generate a random password for me and use that password when creating new users to it.
System is Debian Lenny and script is in bash.
The program is znc. I have made it so that it will generate the random password on the shell but the problem is to use it in the bnc software.
To make a password there the command is znc --makepass and look like this:
My question is now if it would be possible to put in the script so it would "answer" when it need those passwords ? the random password that is generated is in a variable called $setpass and is NOT crypted.
Or is there any other software that would be able to generate that md5 string for me ?
View 7 Replies
View Related
Feb 5, 2011
I cannot seem to get if else statements to work. if $choice == Dog then i want it to say "you selected Dog" The variable choice has the value Dog in it as proved at the end by echo "yes $choice is $choice" following the error Code: ./test.sh: 37: [$choice: not found How do i get the conditional statement to work? What's wrong here? This is the full script:
Code:
#! /bin/sh
: ${DIALOG=dialog}
: ${DIALOG_OK=0}
[code]....
View 7 Replies
View Related
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
Dec 9, 2010
I just noticed there doesn't seem to be a decimal point button on the calculator (gcalctool 5.32.0) when it is in programming mode. I'm using Fedora 14 (32-bit).
View 4 Replies
View Related
Dec 14, 2010
I have a script that creates a textfile with ip addresses and ports, but the ports are in hex format so they need to be converted.
Currently I have this code:
Code:
I'd like to have the second column in decimal instead of hex, like this:
Code:
Is there any way to do that with awk, preferably in a oneliner? Would printf be an option?
View 11 Replies
View Related
Jan 13, 2011
I have a script in the works that reads an MP3 file and gets the track length. Trouble is, it gives me the total seconds, like this:
Sample Track.mp3 = 225.55 seconds
What I'd like to have is that 225.55 converted into minutes:seconds format (in this case, 3:45). How can I do this?
View 10 Replies
View Related
Apr 28, 2010
I just need to perform a simple operation of subtracting two numbers - that aren't whole numbers, i.e 200.56 - 67.24attempting to use expr i merely get "expr: non-numeric argument"
View 3 Replies
View Related
Dec 14, 2010
I have a database of around 4000 files. I use rsync script to transfer from 2 separate updated hdd every month but I need a way to compare a .txt file or .xml file to the updated drive as I cannot use rsync delete because I can not mount all 3 drives at the same time?
View 9 Replies
View Related
Mar 1, 2011
Actually build a script which can monitor the "DateTimeHourMinute" in a data file.
I wanted to compare the "DateTimeHourMinute" from the 2nd column against "DateTimeHourMinute" on the 3rd column which located in the same line.
Below is the data sample:
View 7 Replies
View Related
Jan 3, 2009
I have a large number of files, all of them named /*/*.xyz I need to match them to potential files name /*/*.abc I have tried find -name *xyz |awk '// {print '$NF'}' | awk '{print $NF }' but the result has the full path I just need the filename without the extention, and without the full path.
View 5 Replies
View Related
Aug 21, 2010
I would like to compare to mysql rows as follows:
Select count(*) from stocks2.historical where close*1.05 < (select open from stocks2.historical where date = date_add(date,interval 1 day))
and year(date)=2010;
The problem is with the "date" in bold... i want that date to be the date of the previous row. is there a way to do that purely with mysql? (naturally, i can write a script to go through and compare each date; what i'm asking for is a mysql solution.)
View 3 Replies
View Related
May 23, 2011
I have a (rather large) database of mp3 track information. I also have several directories of the actual mp3s. I'm trying to write a simple bash script that will check the contents of the directories against what's in the database, and upon finding a file that isn't in the database, do something.
Here's what I have so far:
Code:
The trouble I'm having (in the sample directory of "/mnt/music/B/Beatles, The/" the file "Beatles, The - Taxman.mp3" isn't in the database.) is getting it to actually trigger an error when an entry isn't in the database.
Once triggering on a non-entered file is working, any way to get it to traverse the entire /mnt/music hierarchy?
View 13 Replies
View Related
Jul 24, 2011
Whats wrong with this:
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
if(argv[4] == "-verbose")
{
printf("Verbose is on");
[Code]...
View 2 Replies
View Related
Jul 16, 2011
Dear expertsI have files like
ABD : 5869 events, relative ratio : 1.173800E-01 , sum of ratios : 1.173800E-01
VBD : 12147 events, relative ratio : 2.429400E-01 , sum of ratios : 3.603200E-01
SDF : 17000 events, relative ratio : 3.400000E-01 , sum of ratios : 7.003200E-01
[code]....
View 3 Replies
View Related
Jun 22, 2011
I am trying to compare two filenames including the paths. Basically if two paths are similar then my program wants to display message. So I need to check for if two pathnames are same in the sorce and destination. So I was trying for the code to compare tow filename sincluding "" and if the Parent FIle Path is found in the child file path then I need to displays ome message. I was trying to modify something like this:
#!/bin/ksh
# Sample script
file1="C:TextLatestArticleNews.txt"
[code]....
View 7 Replies
View Related
Dec 31, 2010
i am trying this query to compare records of two different tables...i m geting this message!! no required out putvalues for these ($jobTitle $industry $stationBase $gender $maritalStatus)are coming from textboxes!here is the code...
PHP Code:
$query = "(SELECT *,
MATCH(industry, gender, maritalStatus , typeofWorkPosition , preferCity) AGAINST ('$
[code]....
View 4 Replies
View Related
Mar 28, 2011
I have two files with user DN's that exported from two different LDAP directories. I wanted to write a script that reads(checks) users (cn=user1) in file Ack to see if users(cn=user1) exists in file B and give me nice output with what users are missing in file B.I have around 30k users in file A with following format..Quote:
cn=user1,ou=some,o=org
cn=user2,ou=some,o=org
cn=user3,ou=some,o=org
[code]...
View 7 Replies
View Related
Nov 5, 2010
I would like to compare two md5sum outputs to see if the files match. in my script I have
Code:
ORG_FILE="/path/to/org/file.zip"
NEW_FILE="path/to/new/file.zip"
MD5_ORIG=$(md5sum -b "$ORG_FILE")
[code]....
How do I get just the MD5 hash and not the */.... stuff so I can compare them. i tried Code: JUST_HASH=${$MD5_ORIG:0:32} but All I get is
dir_mon_notify.sh: line 79: ${$MD5_ORIG:0:32}: bad substitution
View 1 Replies
View Related
May 15, 2010
I'm writing a loganalysis application and wanted to grab apache log records between two certain dates. Assume that a date is formated as such: 22/Dec/2009:00:19 (day/month/year:hour:minute) Currently, I'm using a regular expression to replace the month name with its numeric value, remove the separators, so the above date is converted to: 221220090019 making a date comparison trivial.. but.. Running a regex on each record for large files, say, one containing a quarter million records, is extremely costly.. is there any other method not involving regex substitution? here's the function doing the convertion/comparison
[Code]...
View 13 Replies
View Related
Dec 9, 2010
how to program in bash, an i have a problem, i am trying compare values in between 2 values (from another file), so far my solution is to make a nested for loop, but that causes it to compare every value. Here is a visulization of what i want
file.a 2,3,4,5
file.b
3 5
[code]...
i want the values 2, 3, 4, 5 from file.a to be compared inbetween values 3 5, 6 9,1 2, 4 7 from file.b (var1 is the value im comparing, var2 is the less value, var 3 is the greater value)
for i in $var1
do
for k in $var2
do
[code]....
my problem with the above code is it compares EVERYINNG, not the values inbetween what i want (which is 3 5, 6 9 etc).
View 8 Replies
View Related
Mar 8, 2010
I want to compare the following two tab-delimited .txt files (both were subsets of the original files) by comparing Columns 3 and 4 simultaneously. It is easy to compare C3 because both C3s are just numbers. But how to compare C4s?Basically, in File1, "G,G" = G in File2, "C,C" = C in File2, "A,A" = A in File2, "T,T"= T in File2.In File2, A/T in Column4 just equals "A,T" or "T,A" in Column4 of File1. C/T in Column4 just equals "C,T" or "T,C" in Column4 of File1, and etc.
File1:
C1C2 C3C4
ih509rs12345467244750"G,G"
ih499rs6049687244911"C,C"
ih508- 7244977"A,A"
[code]....
View 2 Replies
View Related
Feb 15, 2011
I'm working with Radiotap headers right now. I want to get the RSSI data. I came through a problem that I can't figure out right now.The value that I need to get is:
Code:
s8 IEEE80211_RADIOTAP_DBM_ANTSIGNAL
now, when I printf it:
[code]...
View 4 Replies
View Related
Oct 4, 2010
I need to create a script that will compare the differences between two folders and then to copy only the updated and new files only to another directory. I know I need to use rsync here, I can write scripts so really it not how to create a script it is how do I accomplish the transfer of only new or changes files between two folders to a new file. Do I need to link these two folders first and then use the "--compare-dest" switch.
View 8 Replies
View Related
Oct 20, 2010
Have a bash script which contains a line like this:
if [[ ${array[${last}]} =~ "screenpc.PRODUCTION.*" ]]
which WORKED as expected in bash 4.0.33 and now fails in 4.1.2
Instrumented the script to print the value of the left-hand side and it is exactly what is expected.
As noted above, this has been working fine until we installed Fedora 13 (kernel 2.6.33), and now it fails.
Tried setting shell 'extglob' to On with same results.
Did something change? Are there other shell/bash options that need to be set?this has the whole installation stopped!
View 10 Replies
View Related
Nov 19, 2008
I have this program:
#! /usr/bin/perl
use DBI ;
use strict ;
[code]....
and I get this error simply running the program from the command line: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./submit.cgi line 24.
is this the right syntax to use, both, for this line:
my (@param) = $cgi->param("firstname","lastname","type") ;
as well as this one:
$sth=$dbh->prepare ("SELECT firstname,lastname,type FROM dts WHERE firstname LIKE $param[0] AND lastname LIKE $param[1] and type LIKE $param[2]" );
or should there be quotes around the $param[0] or something? (also is it $param[0] or $param(0)?)
View 1 Replies
View Related
Nov 2, 2010
I have a list of names (testnames.txt) and I have a set of log files (testlogdata.log). I'm trying to search the column in my log file for each of the names in my testnames.txt file, and output the result to individual files, name1.txt, name2.txt, name3.txt, etc the names in the column of my log file can appear in different formats , ie the name "Tom Smith" can appear as "tom_smith", "tom-smith", "ACME/tom.smith", "ACME/thomas.smith". etc. To allow for the variations, I have my names in the testnames.txt as expressions, ie, for tom smith, I use the expression "to.*smith", etc.I'm running the following command:
for i in $(cat testnames.txt); do awk '{if ($9~/$i/) print $0}' testlogdata.log > $ioutput.log; done
I want the command to read a value for i, insert it into the if ($9~/inserted value for i/, and dump each line from testlogdata.log into a file named <value-for-i>output.log.
View 4 Replies
View Related
May 26, 2010
Essentially, I am reading the book "Absolute Beginner's Guide to C (Second Edition)", but the biggest problem is that it doesn't have problems nor projects to practice programming. Unfortunately, I do not have the greatest of an imagination to create my own ideas for problems to solve. Does anyone know of any sites that have good problems/projects to work on when I learn throughout the book?
View 6 Replies
View Related