Programming :: Sort IP Addresses For A Bash Program?

Apr 29, 2010

I have for example the following IP addresses:

24.172.220.218
41.239.36.19
63.215.202.234
66.176.124.22

[code]....

How can I sort those IP addresses? I want to sort them using the first 3 numbers I also want to count the number of times that address is repeated This is a batch program.

View 4 Replies


ADVERTISEMENT

Programming :: Bash Shell Scripting / Using The Sort Command To Sort The Top 5 CPU Processes?

Feb 28, 2010

What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?

View 2 Replies View Related

Programming :: Bash To Monitor IP Addresses In A Txt File?

Oct 13, 2010

This code uses ping to check connectivity to a remote location and logs it to a .html file which is then stylized by css..

Code:

#! /bin/bash
path="$HOME/Desktop/IP_Monitor" #Path to write out files
ALT="0" #For styling alternative row

[code]....

I need to add a feature such that instead of hardcoding the ip address .. it takes them from a list and makes new files for each ip address for logging.. And also when log files are completed , They should be compressed using tar. How should i go about adding both these.. This is my first bash script.

View 6 Replies View Related

Programming :: Java Program To Display All IP Addresses In LAN?

Feb 25, 2011

I Want to Develop Network Scanner Software. For that i need "Java Program to Display All IP Addresses in LAN".

View 3 Replies View Related

Programming :: Ping IP Addresses Using Bash (Online Or Unavailable)

Jun 14, 2011

I am new to linux and am trying to write a script that will ping IP addresses and say either online or unavailable.

View 3 Replies View Related

Programming :: Program A SH - Bash Program With Zenity To Play Radio Based On A Site?

Feb 15, 2011

I will have to code this. However I am lacking of time since I have too much to do. make a short code bash/dash to prompt the country with Zenity, then, get the PLS or m3u url and prompt with another zenity which radio to play. http://www.listenlive.eu/index.html

My code to get url's radio country.htm is:

Code:

View 2 Replies View Related

Programming :: Bash Script: Sort Files Into Directory Based On Data In The File Name?

Sep 28, 2010

I have very little linux experience. And need some help with a bash script. I need to a script I can set cron to run to sort files out of a holding folder into final folders. It doesn't necessarily have to be bash, but I think it would be sufficient for this. File names are formatted as such when created: Dest-Date-Time-CID-Destination# I want the files to be moved from a all in one holding folder to a folder structure like this.

.../storage/year/month/day/Destination#/VarX(type)/hour/CID/'File'

I would need an if/else if/else statement to say if Dest = A set VarX = B If for example the file name was

infinity-20100927-17:00-1112223333-4445556666.wav

I would like the above file to end up moved from

.../holding

to

.../storage/2010/09/27/4445556666/Inbound/17/1112223333/infinity-20100927-17:00-1112223333-4445556666.wav

So the script will need to make directories based on information in the file name which is delimited by single dashes. Then move files from the holding folder to the newly created "sorted" folders.

View 15 Replies View Related

Programming :: Run A C Program From Bash Script?

May 9, 2010

I'm trying to write a bash script that helps me building C program then run the C program but I don't know how to make it run.I did like this

Code:
#!/bin/sh
# assuming I've built C program '$output' successfully

[code]....

View 5 Replies View Related

Programming :: Can't Pass Variables To A Program In Bash Script / Fix It?

Dec 30, 2010

Trying to do a simple bash script, and having some issues. I am relatively new to bash, and did my best to search, but idk what exactly to search for.

Doesn't work code...

View 6 Replies View Related

Programming :: BASH Sort List By End Of Line To X Position In Each Line?

Aug 18, 2010

I'm trying to make another file annotation script a little speedier than it has been by the up-until-now proven method of checking the last four characters in a filename before the "dot" (eg .jpg, .psd) against a list of known IPTC categories and Exiv2 command files. It occurred to me that if one script generated a list of files in directory foo, and the same or another script sorted that list by that four-letter tag,then that list could be used(instead of a for/do/done loop on the real files in the folder) by the command-file-matching script to "vomit out" which annotator file would go with file nastynewfile.jpg, f'r'instance. The script I had been using for this task looks like this:

Code:

while read 'line';
do
sp=$(echo $line)
vc=$(echo $sp | cut -d"," -f1)
cv=$(echo $sp | cut -d"," -f2)

[code]....

Where I seem to be stuck is with how to sort the lines in templist, which may be any number of different lengths, from back to front. sort -k looked promising, except it seems only to work the other way round. I thought of invoking a

Code:

q=$(expr length $line); echo $q
n=$[q-8]; echo $n

kind of thing, but that presented the problems of how to sort by those, how to tell sort where to find them (grep?) and how to "stitch them back in" to the original list, which is what I want to sort in the first place.

View 14 Replies View Related

Programming :: Write A Bash Script Program In System Command Terminal?

Mar 22, 2010

I'm trying to write a bash script program in the Linux command terminal that will write to a fellow user and then continue reading down the program. this is what i have (kind of explains the idea too):

#!/bin/sh

clear
echo "this is before the write command"
write jcummins
this message should go to jerry
echo "the message didn't send and this string will not appear"
echo "it appears it has stopped at the write command"

View 5 Replies View Related

Programming :: Changing A Line In A Config File While Installing The Program Using Bash Script

Jul 22, 2011

I am trying to write a bash script that installs a program fully automated for me. I am stuck at the one part where i need to change a line in one config file. I have tried various syntax for sed and none have worked. Maybe someone can suggest how to go about this. Since the line appears in the middle of the file, I can't use echo or cat. Also the file will be diffrent lengths depending on the install.

The line I need changed is:

I need that changed to:

the last syntax i tried is:

Yes this is for PNP4Nagios on centos 5.6 64bit. If i can get this figured out. I will be willing to post the whole thing for others to use. it will be used to install PNP after a working nagios install is done.

View 11 Replies View Related

Programming :: Talented Coder To Program Bash / Perl App That Plays SWF On HTML Page?

Feb 10, 2011

Everyone knows that it is like impossible to use mplayer to watch an *.html file. OK.

For instance here is a cool example of lot of streaming for firefox
http://watchtvlivestreaming.com/tvlive/b5499

Code...

Anyone is there a talented bright coder, coming from hell -because it is really difficult, to make such console program ?

View 1 Replies View Related

Programming :: SORT Command Versus Unix SORT

May 4, 2010

We switched from unix to linux and we have an old report that extracted data from a database, output to an ascii file and then sorted the results in the file based on different arguments. The report now blows up when it runs,and I can only guess it is because the options for sort on linux differ slightly from unix.For example, here is one of the commands issued from within the report app that ran on the old unix box:

if sort-sequence = "descending" then
'sort -t~" -f +3.0f -4.0 +5.0r -6.0 -f '
else
'sort -t~" +3.0f -4.0 +1.0f -2.0 -f'

I will eventually rewrite the report to store the data in a local table, but I can simply adjust the options to suit the requirments of linux. Basically, I need to know if this can be a quick fix for the short term.

View 2 Replies View Related

General :: Writing A Bash Script In BackTrack3 For IP Addresses?

Dec 7, 2009

I was assigned to write a bash script in backtrack which will reveal the active IP Addresses on a /30 network. Normally I would not have a problem with this, but I just dont understand because would you not need the entire prefix (ex: 192.168.1) in order to ping sweep for a certain IP range?basically what I'm asking is...How do I nmap a list of IP's for a "/30 network" as that's all that we're given.

View 3 Replies View Related

Ubuntu :: Using Bash To Sort Csv-files?

Jul 25, 2011

I am in need of sorting the content of a csv-file separated with "#". The file looks the following:

Code:
Descriptive 1#47.5498295127948#35.5365757501888#44.4127802931231#84.0767444257134#0.0416435951243528#0

[code]...

View 8 Replies View Related

General :: Using Sort And Uniq In Bash?

Feb 18, 2011

I have this file with the first lines as follows:

a
a
ability
able

[code]....

say the file is named file1.txt After i do the following:

sort file1.txt | uniq >> file2.txt

I expect that letter a would only appear once, not in two rows, word about would also appear only once. However, I can't seem to get that result using this. I also tried the sort -f file1.txt | uniq >> file2.txt but to no avail. I actually got file1.txt from a messier file using the -f option in sort command.

View 2 Replies View Related

Ubuntu :: Bash To Sort Files Into Subdirectories?

Sep 4, 2010

i currently have hundreds of files all in a single directory. What I would like to do is create 8 subdirectories and move the files into the subdirectories based on the first character of the file name. Ideally, the script would omit any 'the' or 'a' and use the second word for filing purposes. No filenames have spaces. Instead they use periodsThe subdirectories will be:

0-9
a-d
e-h

[code]...

View 2 Replies View Related

Fedora :: Bash Hangs When Command Not Found / Sort It?

Dec 9, 2009

I've been using linux for a long time, and I just ran into a problem that has me stumped. Any time I mistype a command, it says "Command not found."... yea, I know that's normal. But it doesn't return me to my # prompt. I have to press Ctrl+C to get back. code...

I know I do have one issue with this computer, I have 2 blown caps on my motherboard. This was a dual boot system, but after a virus with winblows, I decided to switch it to strictly linux. (roommates... *grumble*) I think I was running fc10 before I wiped the hd & installed fc12. Fc12 does seem to be running slower, and I still haven't got my sound card working properly... but that issue is for another topic...
-YungBlood Reborn

View 2 Replies View Related

General :: Bash - Merging Strings (perhaps With Sort | Uniq)?

Nov 16, 2010

I have multiple strings (eg. say two, firstLIST=(0 1 2) and secondLIST=(2 3)) and want to create a single string composed of their unique sorted elements. For the sample strings above, I'd like to build masterLIST=(0 1 2 3).I suppose I could write the elements of firstLIST and secondLIST to files

Code:

echo ${firstLIST[@]} > firstFILE
echo ${secondLIST[@]} > secondFILE

then use

Code:

sort firstFILE secondFILE | uniq > masterFILE

as this gives me a file populated with the elements I'm after, but I'm not sure how to read the elements back into masterLIST... and it doesn't seem "right" to create files to accomplish this. Is there a way to do this by manipulating the strings ${firstLIST[@]} and ${secondLIST[@]} directly? The closest I've come (not close at all) is

Code:

masterLIST=${firstLIST[@]}" "${secondLIST[@]}

but masterLIST built this way has only one element

Code:

$echo ${masterLIST[@]}
0 1 2 2 3
$echo ${#masterLIST[@]}
1

and I don't have access to the individual digits to then try to figure out how to remove duplicates.

View 4 Replies View Related

Ubuntu :: Graphical Program Over X Without Installing Any Sort Of GUI?

Feb 15, 2011

I have a really old Dell computer (Dell PowerEdge 1300) that I am wanting to use as a small server (samba file server and apt-cacher-ng). I installed Ubuntu server and then did "sudo apt-get install --no-install-recommends ubuntu-desktop" which was a bad idea because it killed the performance.So here is my question.Ive read you can split the X client and server. Would that let me run a graphical program (like Synaptic) over X without installing any sort of GUI on the Dell?If that is the case, how would I go about doing so?If I would still have to install a GUI on the Dell, what are other options since the on-board display adapter seems to struggle with graphics?

View 3 Replies View Related

Programming :: Get Only Ip Addresses & Send It To 3 Files?

May 7, 2010

have a file (called it A) contains;

hostname 192.168.23.65
hostname 10.18.13.253
hostname 10.18.16.253
hostname 177.23.56.58

how can i write a script to get only ip addresses & send it to 3 files with the following info. only:

file1:
192.168.0.0
file2:
10.18.0.0
file3:
177.23.0.0

by creating the 3 files then i will be able to set up subnetmask, gw,....etc.

View 2 Replies View Related

Programming :: Comparing Two IP Addresses - Specific / Restricted

Mar 25, 2011

I want to compare 2 IP addresses, so that I may compare which is more/less "specific" or "restricted" than the other. So is there any function/library that may help in doing this comparison in C (on Ubuntu 10.10)?

View 1 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

Programming :: Faking IP Addresses To Test Servers On Internal Network

Jun 9, 2009

I'm in the process of setting up a script in perl to make 1,000's of curl calls to my companies application on our test server. Our software does all sorts of tracking of data based on IP addresses using geoIP, so i was wondering if anyone knew of a way to fake these addresses to the server?I know a big issue with the IP faking is the return path but i dont really need this. I also cant do it on the hardware level since the script is going to be picking lots of different IP's at random.Anyone have any idea if this is possible and if so, are there any known libraries i can use for this? I prefer perl but any Linux compatiblie scripting language is fine.

View 1 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

Jul 25, 2011

I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.

Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?

View 5 Replies View Related

Ubuntu :: Finding A Program That Will Sort The Music Into Folders Based On Their Genre Tags

Feb 19, 2010

I used MusicBrainz Picard to tag FLAC and Mp3 files, fixed any necessary genre tags in Rhythmbox, and used EasyTag to rename the actual files.But now I'm interested in using those genre tags as folder names...is there any program that will sort my music into folders based on their genre tags?

View 5 Replies View Related

Programming :: Bash: Get Filename And Extension Using Bash?

Jan 9, 2010

I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:

Let FILE="thefilenameofsomefilesfor_instance.txt"

Code:

NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`

I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.

View 5 Replies View Related







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