Programming :: Convert Hex To Decimal Inside Script With Awk

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


ADVERTISEMENT

Programming :: Bash: Convert Decimal To Minutes:seconds?

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

Ubuntu :: New Calculator - Change The Pull Down To 'decimal' Expecting To See The Decimal (base 10) Value

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

Fedora :: No Decimal Point In Programming Calculator?

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

Programming :: Subtract Two Non-real (aka Decimal'd) Numbers Via Bash?

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

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

Software :: Convert Primary Partition To Logical (ie Move It Inside The Extended Partition)?

Nov 29, 2010

Around 2008 i seem to remember PartEd on the command-line was able to rescue deleted partitions and gave a choice of whether to recover the partition as a Primary or Logical Partition. I have tried testdisk but didn't really grok what i was doing. I successfully moved a "Windows Recovery" partition to the end of my hard-drive, immediately after the drive's Extended Partition.

View 3 Replies View Related

Programming :: How To Use A Function Inside A Shell

Apr 28, 2011

I am very new to shell script, and my requirement is --

1. open the apache access log, use "cut" and "grep" to find the numbers.
2.put the result in a file
3.then compare the same result with day before result
4. send the result via e-mail.

so how can i do that , using some functions..

View 1 Replies View Related

Programming :: Use A Class Inside A Struct?

Apr 8, 2011

Is is possible to use a class inside a struct? I keep getting segmentation fault with this code:

Code:

struct my_struct {
unsigned count;
std::string msg;

[code]....

View 3 Replies View Related

Programming :: Call C Executable Inside C

Jan 8, 2010

i have only basic knowledge of C so guys plz help me...is C language support call the C executable inside the C ?example contect mainA.c have a many function define in the struct,when i compile mainA and make a executable the name is ( A ),can i use executable C inside the C <my C program call the executable ( A ) > .

View 9 Replies View Related

Programming :: How To Read File Inside AWK?

Apr 13, 2011

I want to read content of a file inside a gawk script.I know that by using "gawk -f filename" I can read a file, but I want to do that inside the script.

View 7 Replies View Related

Programming :: Include - H Files From Dir Inside Dir?

Feb 2, 2011

Basically I have a dir that contains my makefile and another directory inside this called source this holds main source files. External to these I have a couple of dirs common and drives.

In my make file I use

To include the protoypes from the headers in the folders common and drivers used by source, this works fine. However in common and drivers I use a few variables that are set in the source dir. I set these with externs inside the common and driver files. However I'm sure I should be able to set the directory path for source inside my makefile. So say I have inside source hardware.h with prototypes, I set DINCDIR = -I/Source -I../Drivers -I../CommonFiles

Then from a c file inside my common folder I say #include "hardware.h" the file should be able to see hardware.h and it's protoypes. However I get:

Is there some way I can get the extern dirs to see the source dir?

The set out is something like;

View 1 Replies View Related

Programming :: Script Inside Another Fails To Run / Why Is So?

Feb 2, 2010

I am developing a script for the first time.

I am calling a script B.sh from A.sh
What if B.sh fails to run...how to go about it...

View 3 Replies View Related

Programming :: Convert The Int To A String Using Stringstream Then Convert The String To A Char?

Mar 26, 2011

Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?

View 5 Replies View Related

Programming :: Awk Commands Inside Of A Bash Script ?

May 4, 2011

im pretty sure this is a remedial task for many of you but im having an issue with arrays from a shell script being accessed in an awk command. im pretty good with shell scripting but i am embarrassingly unfamiliar with awk. so here's the meat of the script...


Code:

I am trying to take an input file of ip addresses and corresponding netmasks and put it into a format to be loaded onto a juniper switch. the result should look something like this.. x.x.x.x/netmask using the cidr notation. no matter what subnet is provided though, /32 always gets appended to the end of the ip even when it should be /16, /24, etc... also, the cisco part works fine so that doesnt need any attention.

View 5 Replies View Related

Programming :: How To Redirect Inside Bash Script

Oct 23, 2010

I want to do the following redirectin inside a bash script :

1. all the stdout will be redirected to a /tmp/log

2. all the errors will go to the stderr and also to the /tmp/log.

The following inside a bash script is not working, WHY and HOW to do it:

Rest of the bash script.

View 4 Replies View Related

Programming :: Declaring A Vector Inside A C++ Class?

Mar 23, 2010

Is it not possible to declare a vector inside a C++ class ? Have a look at the following code:

Code:

#include <stdio.h>
#include <iostream>
#include <malloc.h> // malloc
#include <strings.h> // bzero

[code]....

View 2 Replies View Related

Programming :: Getting The Clock Time From Inside A Driver?

Oct 21, 2010

I want to use a function that able to get the current clock time when I call it from inside my wireless driver?

View 1 Replies View Related

Programming :: Match Strings Inside 2 Lists?

Jul 8, 2011

I have that script that checks the nfs mount points:

Code:
#!/bin/ksh
#set -xv
test="DO_NOT_DELETE"
rc=0

[Code]....

I am no expert in loops and it took me all day to write that. I couldn't really tell how to match the string in $df_file and $fs_share, so I did a little workaround with a count.

View 9 Replies View Related

Programming :: Stream Editing Inside The While Loop?

Mar 10, 2010

I have a fallowing ASCII text file:

Code:
Fa0/2 - server1 / testing
Fa0/4 - server2 / production

[code]....

View 7 Replies View Related

Programming :: Two Elements Inside A Form In HTML?

Sep 18, 2010

For a search box on my site, I want a textbox, which will let the user input the term to be searched for, and next to it I want a drop down list that'll have, for example, "Fruit" and "Vegetables" as categories to be searched within. How do I do the HTML for this? (so that the arguments to my search.php script will be eg. "search.php?text=apples&type=fruit" ? )

View 3 Replies View Related

General :: How To Get Decimal Value

Jul 4, 2011

i have a small script that takes the time in seconds(this is a very long number like 615.232145457577) and i convert it to minutes or hours by dividing by 60 or 3600 respectively. I would like to be able to get the result with maybe upto to 2 decimal values.

If i do echo "613.568787987975 / 3600" |bc -l
this gives: .17043577444110416666
How can i just get .17

View 3 Replies View Related

Programming :: Bash Script And Grep Inside File?

Apr 2, 2010

What I'm trying to do is grep [mysqld] from inside my.cnf and then add lines inside the file should they not be there. how do i do that?

View 3 Replies View Related

Programming :: Deadlock Due To Crash Inside Critical Section?

May 12, 2011

The following two pieces of codes share printing to stdout with a POSIX semaphore /dev/shm/sem.abcd

sema1.c:

Code:
int j;
sem_t *sem = sem_open( "/abcd", O_CREAT, S_IRUSR|S_IWUSR, 1 );
j = 0;
while (j < 100) {

[Code].....

If started at the same time, the first will finish in about 10 seconds; the second 20 secs.

What I want to ask is, if the first program crashes at Checkpoint A, then B will never gets to continue, then normally how do programmers avoid this kind of deadlock due to crashes inside the critical section?

View 3 Replies View Related

Programming :: Count Specific Entries Inside A Block?

Jul 15, 2011

What I want to do is from a file having block like

<event>
8 3 0.2685416E-02
2 -1 0
21 -1 0

[code]...

The first line after the "<event>" is its process-id, so I would like to have at the end a summary of how many "event" block I have for each type, ie how many

6 1 0.2685416E-02

or how many

7 2 0.2685416E-02

etc etc

I do not know in advance how many different-kind of block I will have, so it has to be a bit smart to scan the file, and make an new "summary" info for each unique type I was using something like

awk '/<event>/,/</event>/{if ($3 -eq 0.2685416E-02 ) { print $1" "$2" "$3}}' file > out

and then

grep -c "$1" "$2" "$3" but with no success since my awk commands prints all lines of each block

Suppose, that in advance I do know the $3, ie the 0.2685416E-02 which is a kind of weight

View 8 Replies View Related

Programming :: Use AWK To Search For A Specific String Inside Html?

Jan 26, 2010

how to search for a specific string of text inside an html document. I then want to cut out that specific data that the field or string contains. I want to do a shellscript that makes this function automaticly.

For example:

#
#Here i want to find the field "town" inside the html/java and then cut #out the town name from it and paste that to an file.
#
#

[Code].....

View 8 Replies View Related

Programming :: Other Stuff Accessing Data From Inside Gmail?

Jan 10, 2011

I started using Ubuntu's chat tool the other day, I gave it my Gmail username and password,and lo! it found my list of CONTACTS FROM INSIDE GMAIL!Facebook has done the same thing as well! Was this in Google's terms? Can't something be done about this? This is SCARY.But also, a small part of me wants to know how it was done (only a small part, this protocol sh*t is not particularly challenging, right?

View 14 Replies View Related

General :: Add Decimal Numbers?

Aug 10, 2010

Can anyone specify the methods how to add decimal numbers in Linux

View 5 Replies View Related

Programming :: C++ - Snprintf - Inside - For - Doesn't Work As Expected. - Int To Char

Aug 30, 2010

I need to convert an int array into a char* array.

I'm using the following code:

Code:

But it returns me

Code:

View 14 Replies View Related

Programming :: Html Tags Inside PHP Mail Body Message?

Mar 9, 2010

Trying to write a small php program to send emails using a form. I have collected all the information in php variables and I can send the mails just fine. But I need some neat and clean formatting for the mail that is received and hence thought html tables would be nice. But all the html tags are received as plain text and not html though I have mentioned in headers content-type to be html. Any links? If anyone can put some light on it? I thought that html tags would just work fine without much issue. I have tried same with asp and it worked.

PS: I am no programmer. Just trying my hands out on some php.

Edit: I am using a php mailer class from php classes to send mails. I need some way to use an external smtp server for sending mails. I have seen pear but I do not want to use pear. It is not available on the server I am testing and it is not possible for me to install it. I do not have access to install pear and can not ask to install it.

View 7 Replies View Related







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