- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Regarding shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2006 07:38 AM
08-17-2006 07:38 AM
:tcp.max.time.to.wait=180:\ and :runstep.max.time.to.wait=300: User's are asking to do the modification automatically that is via unix script. I had done earlier using sed. But i am not sure how to do this one via unix shell script since there are repeated entries.
fep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=99:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:\
:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:
Netmap.cfg original file contents.
-----------------------------------
topasw2:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=topasw2;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
NDMATTT1:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=NDMATTT1;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
kscadcs1:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=kscadcs1;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
rapprod:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=rapprod;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
ffep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2006 07:41 AM
08-17-2006 07:41 AM
Re: Regarding shell script
:%s/string/newstring/g
which will change from string ---> new string globally in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2006 07:48 AM
08-17-2006 07:48 AM
Solutioncp -p netmap.cfg netmap.cfg.sav #save a backup copy just in case
cat netmap.cfg | sed -e "1,$s/ltattempts=6/ltattempts=99/" >/tmp/mytempfile
echo ":tcp.max.time.to.wait=180:\\" >> /tmp/mytempfile
echo ":runstep.max.time.to.wait=300:" >> /tmp/mytempfile
cat /tmp/mytempfile > netmap.cfg
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2006 08:11 AM
08-17-2006 08:11 AM
Re: Regarding shell script
Here's an awk script example:
BEGIN {fep=0}
{if ( $0 ~ /fep:/ ) { fep=1 }
if ( fep==1 && $0 ~ /:tcp.max.time.to.wait=/ )
{ printf(":tcp.max.time.to.wait=%s:\\\n",tcp); continue }
if ( fep==1 && $0 ~ /:runstep.max.time.to.wait=/ )
{ printf(":runstep.max.time.to.wait=%s:\\\n",run); continue }
if ( fep==1 && $0 ~ /:conn.retry.ltattempts=/ )
{ printf(":conn.retry.ltattempts=%s:\\\n", con); continue }
if ( fep==1 && $1 !~ /:.*/ ) fep=0;
print $0}
Save it to a file (eg. netmap_change.awk) and call it from the commandline as:
awk awk -v con=$con -v tcp=$tcp -v run=$run -f netmap_change.awk netmap.cfg
Your script will have to set the con, tcp, and run variables ahead of time to whatever the users input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2006 08:31 AM
08-17-2006 08:31 AM
Re: Regarding shell script
# perl -pe '$ok=1,next if /^ffep:/;if ($ok) {s/ltattempts=6:/ltattempts=99:/};if (eof) {s/$/\\/};END{print ":tcp.max.time.to.wait=180:\\\n:runstep.max.time.to.wait=300:\n"}' Netmap.cfg
...This should change the 'ltattempts' value, but only under the 'ffep' header; and add a backslash to the last line of the original file before appending the two lines you want to the end.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 01:27 AM
08-21-2006 01:27 AM
Re: Regarding shell script
I had set con=99, run=100,tcp=180 and i ran the below command
awk -v con=$con -v tcp=$tcp -v run=$run -f test.awk netmap.cfg
The fep entry in the netmap.cfg file got changed as below.
fep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=99:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
The belw two lines after last line :pacing.send.count=0: didn't get added after running the script.
:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:
Also after adding these lines i need the
:pacing.send.count=0: end with a backslash
i.d :pacing.send.count=0:\
In the old netmap.cfg in fep entry these two lines tcp and runstep lines are not present. These two lines are new lines that needs to be added after the pacing.send.count line.
Also in fep entry i am able to see two space
before :conn.retry.ltattempts=99:\ had been removed after running the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 01:37 AM
08-21-2006 01:37 AM
Re: Regarding shell script
I suggest you reread my original post. I believe that my perl script accomodates your needs, including the backslash addition.
I would respectfully remind you that you have a good many replies to a good many questions lately to which you have not offered any points. Points add value to later readers in searching for answers that actually worked. Points also offer thanks to those who have helped along the way.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 02:23 AM
08-21-2006 02:23 AM
Re: Regarding shell script
I suggest going with JRF's elegant perl solution at this point unless you have some specific reason not to. The awk script could be modified to add the new lines, but why re-do the work when JRF already did it for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 08:20 AM
08-21-2006 08:20 AM
Re: Regarding shell script
I dont know perl. how do i run this one?
I assign the points at the end when i get answers. Is it a correct way of doing or do i need put points while discussing. I am new to this forum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 08:28 AM
08-21-2006 08:28 AM
Re: Regarding shell script
If you paste the command line, beginning with 'perl' that I posted, you will run the Perl interpreter. My post is simply a commandline perl script.
Every recent HP-UX has Perl. You can see the version you are running by doing"
# perl -v
You can obtain the latest (5.8.8) here should you wish:
http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=PERL
You may certainly assign points at the closure of a thread when you are satisfied that you have a solution. Thank you for asking and thank you for following through. You can read about the point system here:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2006 12:15 AM
08-23-2006 12:15 AM
Re: Regarding shell script
I tried to run it and i am getting the below error
perl -pe '$ok=1,next if /^ffep:/;if ($ok) {s/ltattempts=6:/ltattempts=99:/};if (eof) {s/$/\\/};END{print ":tcp.max.time.to.wait=180:\\\n:runstep.max.time.to.wait=300:\n"}' netmap.cfg
syntax error in file /tmp/perl-ea13388 at line 1, next 2 tokens "END{"
syntax error in file /tmp/perl-ea13388 at line 2, next token "}"
Execution of /tmp/perl-ea13388 aborted due to compilation errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2006 02:12 AM
09-05-2006 02:12 AM