UNIX.com
UNIX and Linux Forums - Learn UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts
URL: http://www.unix.com/
Updated: 26 min 8 sec ago
Help with perl script while reading a file
Hi Everyone, I am very new to perl, but came across a situation wherein I have to read a c++ header file and write the datatype, its identifier and also the length to an excel file. There can be other header files, in the directory but I should browse through the file which has only "_mef:" string in it. Once I have such a file, then I should again browse through the file to find out the native datatypes, such as int, char, short etc....and write the identifier and its length to csv file.
For example..
header.h
Code: class a_mef:public data
{
public:
char a;
short value;
float val;
char b[10];
} Then the csv file should have the output as
header.h (Name of the header file)
Code: Field Type Length
a char 1
value short 2
val float 4
b char 10 I would greatly appreciate if anyone can help me to achieve this.
Regards,
RB
For example..
header.h
Code: class a_mef:public data
{
public:
char a;
short value;
float val;
char b[10];
} Then the csv file should have the output as
header.h (Name of the header file)
Code: Field Type Length
a char 1
value short 2
val float 4
b char 10 I would greatly appreciate if anyone can help me to achieve this.
Regards,
RB
getting number of disks inside a solaris zone
Friends, I am really stuck on this one. In solaris i can get the number of disks using this command -->
Code: pfexec format | egrep -v "Searching|AVAILABLE|Specify|^$|@" | wc -l But when applying this command inside a solaris zone ,the format command doesnt work. any ideas on how i can go about it
Code: pfexec format | egrep -v "Searching|AVAILABLE|Specify|^$|@" | wc -l But when applying this command inside a solaris zone ,the format command doesnt work. any ideas on how i can go about it
TechCast Live: Jono Bacon and Luke Kowalski on MySQL Community
June 8, 2010, 10 am PDT What makes a productive, thriving community? Look no further than the MySQL example. Bring your questions; we'll answer them in this live, interactive Webcast.
More...
More...
Perl References/Dereferences
Can someone explain where can we actually used
Code: print $var->[0];
or
print $$var[0] When does the -> becomes necessary and when its optional.
Code: print $var->[0];
or
print $$var[0] When does the -> becomes necessary and when its optional.
help with changeing permissions on my second hard drive
Hello
I have just started using unix /ubanti and want to know how i can change permissions on my second hard drive. now i cannot use it except looking at text files . It used to be my winxp hard drive and i'd like to use it for things.
Don spaulding
I have just started using unix /ubanti and want to know how i can change permissions on my second hard drive. now i cannot use it except looking at text files . It used to be my winxp hard drive and i'd like to use it for things.
Don spaulding
Rebooting 3 to 1 Cluster nodes.
hello Gurus,
My current set up is 3 to 1 Cluster (SUN Cluster 3.2) running oracle database. Task is to reboot the servers. My query is about the procedure to do the same.
My understanding is suspend the databases to avoid switchover. Then execute the command scshutdown to down the cluster and i'll be at OK prompt. Please help with the correct procedure.
Thanks in advance.
My current set up is 3 to 1 Cluster (SUN Cluster 3.2) running oracle database. Task is to reboot the servers. My query is about the procedure to do the same.
My understanding is suspend the databases to avoid switchover. Then execute the command scshutdown to down the cluster and i'll be at OK prompt. Please help with the correct procedure.
Thanks in advance.
xmlstarlet parse field from file
I have a xmlfile like this:
Code: <?xml version="1.0" encoding="utf-8"?>
<contentlocation xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="http://wherein.yahooapis.com/v1/schema" xml:lang="en">
<processingTime>0.001538</processingTime>
<version> build 091119</version>
<documentLength>101</documentLength>
<document>
<administrativeScope>
<woeId>2430456</woeId>
<type>Town</type>
<name><![CDATA[Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.6401</latitude>
<longitude>-155.996</longitude>
</centroid>
</administrativeScope>
<geographicScope>
<woeId>12798285</woeId>
<type>Zip</type>
<name><![CDATA[96740, Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.7118</latitude>
<longitude>-155.892</longitude>
</centroid>
</geographicScope>
<extents>
<center>
<latitude>19.7</latitude>
<longitude>-155.9</longitude>
</center>
<southWest>
<latitude>19.5288</latitude>
<longitude>-156.062</longitude>
</southWest>
<northEast>
<latitude>19.8984</latitude>
<longitude>-155.725</longitude>
</northEast>
</extents>
<placeDetails>
<place>
<woeId>12798285</woeId>
<type>Zip</type>
<name><![CDATA[96740, Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.7</latitude>
<longitude>-155.9</longitude>
</centroid>
</place>
<matchType>1</matchType>
<weight>1</weight>
<confidence>10</confidence>
</placeDetails>
<referenceList>
<reference>
<woeIds>12798285</woeIds>
<start>-1</start>
<end>-1</end>
<isPlaintextMarker>0</isPlaintextMarker>
<text><![CDATA[]]></text>
<type>xpath</type>
<xpath><![CDATA[/div[1]/span[2]]]></xpath>
</reference>
</referenceList>
</document>
</contentlocation> which is valid xml, according to xmlstarlet val xmfile, I'm trying to run a query like this:
Code: xmlstarlet sel -t -m "//geographicScope" -v "name" -n xmlfile but it's returning nothing, what am I doing wrong? I try a similar query on another type of xml file I have on this machine and it returns the right results.
---------- Post updated at 04:47 PM ---------- Previous update was at 02:35 PM ----------
got it working by piping to xml2, definitely not the best way I guess, but this works:
Code: url=`curl --silent -X POST -ddocumentContent='<div class="geo">GEO: \
<span class="latitude">'${lat}'</span>, <span class="longitude">'${lon}'</span></div>' \
-ddocumentType='text/html' -dappid='myidat@yahoo.com' http://wherein.yahooapis.com/v1/document`
address=`echo $url | xml2 | grep contentlocation | grep document | grep geographicScope | grep name | cut -c48-` had to get something working quick.
Code: <?xml version="1.0" encoding="utf-8"?>
<contentlocation xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="http://wherein.yahooapis.com/v1/schema" xml:lang="en">
<processingTime>0.001538</processingTime>
<version> build 091119</version>
<documentLength>101</documentLength>
<document>
<administrativeScope>
<woeId>2430456</woeId>
<type>Town</type>
<name><![CDATA[Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.6401</latitude>
<longitude>-155.996</longitude>
</centroid>
</administrativeScope>
<geographicScope>
<woeId>12798285</woeId>
<type>Zip</type>
<name><![CDATA[96740, Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.7118</latitude>
<longitude>-155.892</longitude>
</centroid>
</geographicScope>
<extents>
<center>
<latitude>19.7</latitude>
<longitude>-155.9</longitude>
</center>
<southWest>
<latitude>19.5288</latitude>
<longitude>-156.062</longitude>
</southWest>
<northEast>
<latitude>19.8984</latitude>
<longitude>-155.725</longitude>
</northEast>
</extents>
<placeDetails>
<place>
<woeId>12798285</woeId>
<type>Zip</type>
<name><![CDATA[96740, Kailua Kona, HI, US]]></name>
<centroid>
<latitude>19.7</latitude>
<longitude>-155.9</longitude>
</centroid>
</place>
<matchType>1</matchType>
<weight>1</weight>
<confidence>10</confidence>
</placeDetails>
<referenceList>
<reference>
<woeIds>12798285</woeIds>
<start>-1</start>
<end>-1</end>
<isPlaintextMarker>0</isPlaintextMarker>
<text><![CDATA[]]></text>
<type>xpath</type>
<xpath><![CDATA[/div[1]/span[2]]]></xpath>
</reference>
</referenceList>
</document>
</contentlocation> which is valid xml, according to xmlstarlet val xmfile, I'm trying to run a query like this:
Code: xmlstarlet sel -t -m "//geographicScope" -v "name" -n xmlfile but it's returning nothing, what am I doing wrong? I try a similar query on another type of xml file I have on this machine and it returns the right results.
---------- Post updated at 04:47 PM ---------- Previous update was at 02:35 PM ----------
got it working by piping to xml2, definitely not the best way I guess, but this works:
Code: url=`curl --silent -X POST -ddocumentContent='<div class="geo">GEO: \
<span class="latitude">'${lat}'</span>, <span class="longitude">'${lon}'</span></div>' \
-ddocumentType='text/html' -dappid='myidat@yahoo.com' http://wherein.yahooapis.com/v1/document`
address=`echo $url | xml2 | grep contentlocation | grep document | grep geographicScope | grep name | cut -c48-` had to get something working quick.
Cannot award a posting with bits!
Hi all,
I've just now wanted to award 1000 Bits to following posting and I noticed there is no "coin"/award button anymore :confused:
http://www.unix.com/302423330-post2.html
Regards,
pc
EDIT: I guess it's turned off since we now have this Thanks button?
I've just now wanted to award 1000 Bits to following posting and I noticed there is no "coin"/award button anymore :confused:
http://www.unix.com/302423330-post2.html
Regards,
pc
EDIT: I guess it's turned off since we now have this Thanks button?
Renumber column using Awk
I have a data set similar to that below and I need to add a column $2 (which numbers the lines from 1- end)
Text Input Output x y z
Text Input Output x y z
Text Input Output x y z
Text Input Output x y z
I also need to have various column widths so $1 is 6 spaces $2 is 5, $3 is 5, $4 is 7. I have used awk '{print FNR "\t" $2}' and now have a tab delineated file (which is numbered). Can anyone help adjusting the output? I do not understand how to use the printf commands to specify column width.
Thank you for any assistance you are willing to share
Text Input Output x y z
Text Input Output x y z
Text Input Output x y z
Text Input Output x y z
I also need to have various column widths so $1 is 6 spaces $2 is 5, $3 is 5, $4 is 7. I have used awk '{print FNR "\t" $2}' and now have a tab delineated file (which is numbered). Can anyone help adjusting the output? I do not understand how to use the printf commands to specify column width.
Thank you for any assistance you are willing to share
Solaris 2.6 restore from tape
Hope someone can help me here...
I've got to restore an E450 with 300MHz cpus which was running Solaris 2.6 from tape. Regrettably the boot drive has failed.
I've access to the first release of Solaris 2.6 CD's and to a set of Solaris 9 CD's.
I remember that different E450 CPUs needed different releases of the 2.6 media set in order to boot correctly.
The tape was written using ufsdump.
So, to my questions?
Will this E450 boot from the Solaris 2.6 CD?
If not, will booting from the Solaris 9 CD be able to ufsrestore and then installboot correctly?
According to the notes I have of the restore process, while booted from the CD I'd issue this command to install the boot block:
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0
but if I'm booted from a Solaris 9 CD would that result in a valid boot block for Solaris 2.6?
Many thanks for any and all assistance.
I've got to restore an E450 with 300MHz cpus which was running Solaris 2.6 from tape. Regrettably the boot drive has failed.
I've access to the first release of Solaris 2.6 CD's and to a set of Solaris 9 CD's.
I remember that different E450 CPUs needed different releases of the 2.6 media set in order to boot correctly.
The tape was written using ufsdump.
So, to my questions?
Will this E450 boot from the Solaris 2.6 CD?
If not, will booting from the Solaris 9 CD be able to ufsrestore and then installboot correctly?
According to the notes I have of the restore process, while booted from the CD I'd issue this command to install the boot block:
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0
but if I'm booted from a Solaris 9 CD would that result in a valid boot block for Solaris 2.6?
Many thanks for any and all assistance.
SCSI drive
Hi i ahve a SCSI drive that it use to work but now is not working. The Sun machine can not read the drive. My question is there is any other way to get the data back from the SCSI drive? I think if i replace the chip board on teh SCSI drive it might help to just buy a new Board but there is any UNIX command to fix the hard drive like in windows we use CHKDSK /f/r
How can i extract the data out it a SCSI drive? doe smy question?
thank you
How can i extract the data out it a SCSI drive? doe smy question?
thank you
What's wrong with my script ....
Please see below mentioned my script ... it ran once without any issue .... then after it is not coming out .... please suggest what is wrong?
Code: #!/bin/ksh
## if (( ${num_errors} > 0 ));
export ACULOG=/home/varshnes/input
export num_errors=10
**** Search for 'Start correcting roll up conflicts' ****
STRING=$(find $ACULOG -name "*" | xargs grep -i "Start" | grep -i "correcting" | wc -l)
echo $STRING
if (( ${STRING} > 0 ));
then
echo -n "$num_errors "
num_errors=`expr $num_errors - 1`
fi
STRING=$(find $ACULOG -name "*" | xargs grep -i "End" | grep -i "correcting" | wc -l)
echo $STRING
if (( ${STRING} > 0 ));
then
echo -n "$status "
num_errors=`expr $num_errors - 1`
fi
echo -n "$num_errors "
if (( ${num_errors} > 0 ));
then
echo "SEND MAIL NOW"
fi
exit 0
Code: #!/bin/ksh
## if (( ${num_errors} > 0 ));
export ACULOG=/home/varshnes/input
export num_errors=10
**** Search for 'Start correcting roll up conflicts' ****
STRING=$(find $ACULOG -name "*" | xargs grep -i "Start" | grep -i "correcting" | wc -l)
echo $STRING
if (( ${STRING} > 0 ));
then
echo -n "$num_errors "
num_errors=`expr $num_errors - 1`
fi
STRING=$(find $ACULOG -name "*" | xargs grep -i "End" | grep -i "correcting" | wc -l)
echo $STRING
if (( ${STRING} > 0 ));
then
echo -n "$status "
num_errors=`expr $num_errors - 1`
fi
echo -n "$num_errors "
if (( ${num_errors} > 0 ));
then
echo "SEND MAIL NOW"
fi
exit 0

Recent comments
2 weeks 12 hours ago
2 weeks 4 days ago
14 weeks 3 days ago
17 weeks 5 days ago
21 weeks 6 days ago
22 weeks 8 hours ago
22 weeks 23 hours ago
24 weeks 2 days ago
27 weeks 2 days ago
29 weeks 9 hours ago