Programming :: How To Parse And Modify Keywords Using Shell Script?

Apr 14, 2011

There is a file with that format of each models' information.I don't think that's good format, but I cannot change that format. I needed to modify the model name, 'model = xxx' as 'model = abc'.And I don't know how to parse and modify 'model = iii' and 'model = ddd'.The only clue to parse 'model = ddd' is the second 'model = ' after the second 'system information'. But how to parse the second keyword?Is it possible with 'sed'?I sometimes have to modify the information of the file.using shell script if possible.Python is ok. (Shell script is better for me.)

View 15 Replies


ADVERTISEMENT

Programming :: Parse And Modify File Without Creating A Copy?

Nov 4, 2010

I don't think this is a "perl one-liner" of find and replace. I'm trying to auto-fill some information in a listing of files. The simplest example is that in the files the following exists:

I would want the script to find this and populate it with something like -- Date : 20101004-1758

I have a few more similar fields to autofill, and I'd like to do this from within a larger perl script I'm developing to process these files. So, how I perform in-place file modification from within a perl script?

View 3 Replies View Related

Programming :: Modify Output Of Shell Script

Dec 3, 2010

I'm running RHEL5.5 and nagios 3.2.0. The real question deals with how to change the printed output so nagios will work with it.I have made a script that will calculate network throughput on interfaces. The script is going through and finding all interfaces (eth, bond, lan) and doing the math to calculate throughput.The output is mainly for nagios to report and trend the values. As nagios wants to see nothing but perf data after the '|' character, I somehow need to have only one '|' character for all of the output.

View 2 Replies View Related

General :: Custom Syntax Highlighting In Bash Shell - Using Keywords

Apr 25, 2011

I know it's possible to change the $ user@hostname colors, but is it possible to color different things? Could I make all numbers/integers a certain color. Or set certain keywords to be bold?

View 1 Replies View Related

Programming :: Bash : Searching For Info And Changing The Color Of Keywords In The Results?

May 5, 2011

(bare with me as I am sort of new with scripting) I am trying to figure out how to run a script that does a basic chkconfig and to get only those services that are running, but changing the color of "on" to red in my output file. Here is what I am working with so far:

Quote:

#/bin/bash
RED=$(tput setaf 1)
BLK=$(tput setaf 0)

[code]....

*I had to substitute a "-" and <colon_symbol> for ":" in front of the on's, because the forum thought they were smiley faces (i.e. n) how to make the "on" to be red while the rest of everything remains in black text. I have been trying to read up on sed and awk, but it is still pretty much a mystery to me right now. There will be other things in the output file that I wouldn't want a rogue "on" to be in red, so just the instances of "on" in that one chkconfig return.

View 4 Replies View Related

General :: Shell Scripting: Parse Parameters From Command Line?

Mar 12, 2010

myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory

Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?

View 1 Replies View Related

Debian Multimedia :: Conky Execp / Execpi To Parse Output Of Scroll Variable Generated From Shell Or PHP Scripts

Sep 11, 2015

I am having a hard time getting conky execp/execpi to correctly parse output of the scroll variable generated from shell or PHP scripts.

Code: Select allDebian 8.0
Xfce 4.10
Conky 1.9.0-6

This is a simplified minimal conky configuration file used to show the same problem:

Code: Select allalignment bottom_middle
background no
border_width 1
default_color white
default_outline_color white
default_shade_color white
double_buffer yes

[Code] ....

Here is the output I'm getting:

Code: Select all          ABC       /*doesn't scroll, UNEXPECTED, shows 10 spaces before ABC*/
          ABC       --||--
abcdefghijklmnopABC /*doesn't scroll, WORKS AS EXPECTED as scroll length is 25 which is longer than text "abcdefghijklmnop" */
abcdefghijklmnopABC --||--
abcdefghijklmnopABC /*WORKS, everything before ABC scrolls 5 characters at a time*/

View 0 Replies View Related

Debian Configuration :: How To Modify Source.list From Shell?

Jan 27, 2011

how can i manually modify source.list to include debian repository from shell.since xorg isn't installed yet and the cd doesn't work well.

View 5 Replies View Related

Fedora :: Modify Start Up Files Of Sh-based Shell

Sep 2, 2011

i need to add a line in the login start up file(s) (one of ~/.bash_profile, ~/.bash_login, or ~/.profile) and startup file run by my shell when started as a non-login shell (~/.bashrc) so as to set up my account envirnoment for one of my courses.I don't know how to proceed with this. I tried doing this in my ubuntu enviroment and my system got locked after that.

View 3 Replies View Related

General :: How To Modify Line Of File Using Shell Script?

Apr 12, 2010

I have a file like below
n
p
1
1
50
w

I need to modify the first occurence of 1 byt some other integer.How do i do it using shell script?Can anybode help me out with that?

View 9 Replies View Related

Programming :: Perl: Find Variable Text Between Keywords And Replace W/ "term_<variable_text>_term"?

Jul 12, 2010

I am trying to write a Perl script that can open a file, find text that appears between two identifying strings (for now, "start" and "end"), then modify that text by enclosing it between "term_" and "_term" . Since the identified strings vary, the replacement string becomes "term_$1_term". From looking at other threads in this forum I've been able to get as far as spitting out the modified terms using the following code:

open FILE, "start2.txt" || die ("Could not open file <br> $!");
$text = <FILE>;
while ($text=~ s/start (.*?) end//) {

[code]....

The problem is how to get "term_$1_term" into the file in the same while loop, which I'm guessing would be some of variant of "$text=~ s/$1/$term/;" (which doesn't work as it stands).

View 6 Replies View Related

General :: Modify A File Like /etc/gdm/custom.conf From The Shell Or A Script?

Jun 22, 2010

I want to modify a file like /etc/gdm/custom.conf from the shell or a script.

# GDM configuration storage
[xdmcp]
[debug]
[daemon]
AutomaticLoginEnable=true;
AutomaticLogin=username;

But the idea is that I can add a line to a section and it check if the section is defined, (add the definition if not), the property is defined, let it undefine (erase the line), (and delete the section header if there is no property defined), etc...

I didn't find anything except gconftool-2 but it do not explain how to modify other files. (there is a shema file there).

there isn't a program/script to achieve this, but can easyly be made for every config file, If someone do something like that, with a little database of which markup use each file, it could become really popular.

View 3 Replies View Related

General :: Desire Trick To Modify Hostname In Shell Script

Mar 28, 2011

I am looking an neat trick / elegant solution to manipulate / modify hostname and set a variable to the value inside a script.I have figured what I want to do.I just want to know how to set the variable correctly ?

View 1 Replies View Related

Programming :: Best Command To Use To Parse Strings?

Mar 24, 2010

what is the best command to use to parse strings?I have a variable $str and need to parse this string.Can you provide an example of the command used to get a substring of $str based on the index values of start and end

View 3 Replies View Related

Programming :: Awk Parse String With Space?

Feb 4, 2010

How to let awk consider a string by double quota as one field? for example:

echo "first "second is a string"" | awk '{ print $2 }'

I want to print out "second is a string".

View 8 Replies View Related

Programming :: Parse Error In Php Code?

Jan 20, 2011

I am novice. I am trying to create one email form. But i am getting "Parse error: parse error in F:estwampwwwsendmail.php on line 43"

Code:
<?php
if(isset($_POST['email'])) {

[code]....

View 3 Replies View Related

Programming :: Parse XML To Get IP Adresses Only Using Bash

Jul 28, 2010

I got this xml

...
<other stuff="etc">...</other>
<cluster id="1">
<host ipaddress="192.168.50.1" name="server1">
<host ipaddress="192.168.50.2" name="server2">
<host ipaddress="192.168.50.3" name="server3">
</cluster>
...

how would i get the ip addresses only using bash.

View 4 Replies View Related

Programming :: PHP - How To Parse Data Into Variables

Apr 17, 2011

My php knowledge is very poor (only worked with strings so far), and I am faced which a task that is a real challenge for me: I have a variable, that contains data of different type, in this order: byte, byte, string, string, string, string, short, byte, byte, byte, byte, byte, byte, byte, string.

Strings are of variable length. How could this data be parsed into variables of the right type, and then all converted to strings? What are the functions to use? Strings are unicode ones, and they are delimited by "

View 4 Replies View Related

Programming :: Parse A File Containing Billions Of Records?

Nov 17, 2010

I have to parse a file containing billions of records and populate them in the Data structure. I have used a lot of C++ class and creating objects of the class I am storing the information retrieved by parsing the file.

Now as the file become huge and number of objects become very large my code is getting bad_alloc error as it is not finding any space avalable in the heap for allocating new object.

Is there any way to parse the file?

View 7 Replies View Related

Programming :: Parse The File Correctly With Python

Nov 27, 2010

I'm currently curios with my python program which the basic goal is to parse the character in mytestfile;let's see the code

Code:
f=open('/home/andrewraharjo/Desktop/snort.log','r')
j=f.read()

[code]...

View 3 Replies View Related

Programming :: Parse Text For Host List?

Feb 22, 2011

To run a parallel chemistry program, I need to build the host list. The cluster already has SGE(grid engine) installed and it generates a host list file with the following contents:

compute-1-1.local 2 all.q@compute-1-1.local UNDEFINED
compute-2-1.local 2 all.q@compute-1-1.local UNDEFINED

The important bits are hostname(ex compute-1-1) and number of cpus to use(ex 2). And for this program, it wants them in this form, a shell variable: HOSTLIST=hostname:cpus=X hostname:cpus=X .... I've tried this script, but it doesn't work

Code:

#!/bin/bash
spacer=":cpus="
let count=0

[code]....

View 5 Replies View Related

Programming :: PHP Parse Error Using WAMP Server?

Apr 19, 2010

I have a basic HTML file set up which allows my to input some data. I have a MySql database set up behind the scenes with a table for this information to go in. When I click the submit button in my HTML file this PHP file opens and it comes up with "Parse error: parse error in C:wampwwwcomp39xinsert_student.php on line 32"Here is my code I am using in the PHP file:-

<html>
<head>
<title>COMP 39x FInal Year Project - Student Added?</title>

[code]....

View 2 Replies View Related

Programming :: Read A File And Parse A String In C++

Jul 26, 2010

I need to read a file and parse a string. I know in Perl there is the split command. Is there something similar to that in C++?

View 6 Replies View Related

Programming :: Bash - Parse Apache Log For Requests Per CIDR / 24

Feb 6, 2011

I'm trying to figure out how I can get a request count per CIDR/24 from an apache log in combined format - e.g.:
Code:
24.147.44.122 - frank [10/Oct/2011:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "[URL] "Mozilla/4.08 [en] (Win98; I ;Nav)"

I'm stuck using BASH for this and I generally write everything in Python, or even Perl if necessary so BASH isn't the most comfortable for me. I've got enough to extract the IPs and get a count I just need a slick way to come up with a sum on a per CIDR basis.

View 3 Replies View Related

Programming :: Configure Httpd.conf To Parse .php Files?

Jul 5, 2010

what's the difference between the following 2 methods for specifying in httpd.conf to use PHP to parse files with extension .php?

Method 1
AddType application/x-httpd-php .php
Method 2
LoadModule php5_module modules/libphp5.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>

View 2 Replies View Related

Programming :: Parse Files With Variable Record Length?

Aug 6, 2010

I would like to extract Room number, Lastname,Firstname,invoice (205880080),arrival date, departure date, and total(229.46). Can you at least give me a hint on how to proceed? I have tried a lot but I am stumped from the beginning.

***History***
Room: 124 B Payment: Bell/TRAVELSCAPE.COM
Lastname*FIT*,Firstname 4A, 0K, 0B Guest
Bell *205880080 FT
Bell *205880080 July 31, 2010

[Code]...

View 4 Replies View Related

Programming :: Get Parse Error When Connect The Page With A Database

Jan 27, 2011

I'm creating a comment form for a website but when I try to connect the page with a database it gives me a parse error. here are the codes I wrote:

[Code]....

View 1 Replies View Related

Programming :: Parse Final Domain From Redirect Link ?

Jun 2, 2011

I have a collection of redirect links I need to grab the final domain from (indicated after "->"):

[url]
[url]

I'm thinking PHP/cURL is the way to do it. I've searched the net but failed to find a solution that works for all redirection links.

View 2 Replies View Related

Programming :: Parse HTML And Print Specific Table?

May 13, 2009

I'm trying to write a script that will spider a particular webpage that shows the current inventory for their products. I need to figure out the optimal method of parsing the web page, and extracting the <td> line for the "qty" for "Product 2":

Code:

<table border="0" width="100%" cellspacing="1" cellpadding="3">
<tr>
<td align="left" style="background-color: #EAEAFF; border-bottom-style: solid; border-bottom-width: 1" nowrap width="20%" height="50">
<p align="left"><font face="Arial" size="2"><b> Evaluation

[code[.....

View 4 Replies View Related

Programming :: Perl Read File And Parse Blocks?

Aug 21, 2010

I am trying to make a perl script which reads data from a file and parse it. The data in the file has the following syntax

Code:
Device Physical Name : Not Visible
Device Symmetrix Name : 1234
Device Serial ID : N/A
Attached BCV Device : N/A
Device Capacity

[Code]...

Each unique record starts with "Device Physical Name". So, I have a set of records within "Device Physical Name". I want to read this set of records starting from "Device Physical Name" and ends up till next "Device Physical Name". Offcourse FS is ":", and I just want to print/or later put info in a csv file.

View 14 Replies View Related







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