niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
Passing parameters back from a function
Post new topic   Reply to topic Page 1 of 43 [637 Posts] View previous topic :: View next topic
Goto page:  1, 2, 3, ..., 41, 42, 43 Next
Author Message
Ines Schmitt
*nix forums beginner


Joined: 18 Jul 2006
Posts: 1

PostPosted: Tue Jul 18, 2006 7:06 pm    Post subject: Re: HP-UX 11.x and Legato Networker 5.5 Reply with quote

X-No-archive: yes

Hi James,

we are running Networker 7.1.3 on HPUX Itanium and beside the problem of
the non-existing persistent binding solution for tape devices it is
running well. Version 5.5 seems to be rather old, since 7.3.1 is the
current release. I am sorry that I could not help with your specific
problem but I would like to give You a link to a mailinglist where many
Legato networker users gave really helpful tips. I guess You will find a
helpful answer there. HTH

http://www.lsoft.com/scripts/wl.exe?SL1=NETWORKER&H=LISTSERV.TEMPLE.EDU

Ines

Am 18.07.2006 hast Du geschrieben:

Quote:
James wrote:

Can someone point out why:
1. These Legato issues are occurring
2. Why this script is overloading processes (nsrd loads at least one
nsrexecd and two nsrexex processes when started)

Thanks.

BTW, the primary shell is /bin/sh.

A few other notes that I've encountered.
Legato continually has issues with Cleaning Tapes and predefined slots,
Read error: no such device or addess,
The client one week decides it's a server resulting in a license issue
that was resolved
Back to top
James
*nix forums Guru


Joined: 09 Jun 2003
Posts: 306

PostPosted: Tue Jul 18, 2006 5:40 pm    Post subject: Re: HP-UX 11.x and Legato Networker 5.5 Reply with quote

James wrote:
Quote:
Hello,

I work for a company who uses Legato Networker to backup their HP-UX
systems.

The problem is Legato. It seems that on one particular server, Legato
wants to fail at least once a week. Multiple sites are supported
solely by me, and I have spent many weeks restoring Legato directories
when it crashes or encounters wierd problems, and then updating the
indexes and checking on the settings to make sure nothing has changed
(online and offline notes are kept on the settings for each server).

The thing that makes this difficult is that I am not allowed to install
software such as snort, sudo or tripwire. Furthermore, it seems that
although a limited number of people know the root password (i.e 1-2
people plus myself, as I am root), certain things are happening that
would require the root password. Physical security is not optimal, and
I have to sleep a small number of hours to keep my sanity, otherwise I
would be onsite or connected otherwise all the time.

A recent issue that concerns me is the numbe of times it's primary
daemons disappear from the process table, forciong me to go in and
restart it manually and watch the system. I had written a script to
automatically check and restart the processes, but it didn't work
correctly so it was removed from cron.

No signs of external intrusion are found, so it seems to me it would be
a system issue or internal access to the console for some odd reason to
only kill this application nightly this week.

Here is the script that was written:
#!/bin/sh
outfile="/nsr_up.txt"
touch $outfile
echo "Number of processes on host total: `ps -ef | grep nsr | wc -l`"
$outfile
ps -ef | grep nsrd
if [ "$?" -eq 0 ]; then
echo "Exit value of last command was unsuccessful" >> $outfile
/opt/networker/bin/nsrd
/opt/networker/bin/nsrexecd
echo "" >> $outfile
echo "NSR processes started at `date`" >> $outfile
echo "Number of NSR process running on host total: `ps -ef | grep nsr
| wc -l`" >> $outfile
ps -ef | grep nsr >> $outfile
sleep 1
fi
mailx root@myhost.ext < $outfile
mailx me@externaladdr.ext < $outfile
rm $outfile


Can someone point out why:
1. These Legato issues are occurring
2. Why this script is overloading processes (nsrd loads at least one
nsrexecd and two nsrexex processes when started)

Thanks.

BTW, the primary shell is /bin/sh.

A few other notes that I've encountered.
Legato continually has issues with Cleaning Tapes and predefined slots,
Read error: no such device or addess,
The client one week decides it's a server resulting in a license issue
that was resolved

Thanks in advance.
Back to top
bsh
*nix forums Guru Wannabe


Joined: 01 Mar 2005
Posts: 125

PostPosted: Tue Jul 04, 2006 1:44 am    Post subject: Re: Bourne shell read question Reply with quote

Chris F.A. Johnson wrote:
Quote:
On 2006-06-28, swangdb wrote:
...
It is the while loop, not the disc access that is slow.

No, it is the way that redirection is implemented within
a while (or any other) loop, that redundant syscalls are
slowing down the while loop itself.

The while loop (unfortunately) creates a new process
environment to execute the loop body, thereby
presumably copying the environment (and FDs)
multiple times.

Quote:
From David Butcher's investigation, "Speeding Up Your
UNIX Shell Scripts" at

http://www.los-gatos.ca.us/davidbu/faster_sh.html :

"Conclusion: a 500% speedup [results from] use of file
descriptor manipulation, instead of [by using] input
redirection ... in a while loop."

Try the workaround demonstrated in the file mentioned above.

=Brian
Back to top
Michael Paoli
*nix forums Guru Wannabe


Joined: 10 Oct 2005
Posts: 107

PostPosted: Sun Jun 11, 2006 10:23 pm    Post subject: Re: sed, remove last new line Reply with quote

quarkLore wrote:
Quote:
and
sed '$,$s/^.*$/whatever/' test
removes the last "line" not the last new-line character.

Well, it replaces the last line, but doesn't strip the newline
character, as would the equivalent:
sed -e '$s/^.*$/whatever/' test
sed(1) probably isn't the correct tool to use if one wants to strip
the last newline character from the last line ... unless it just
happens to be the case that one wants precisely nothing output in
place of that last line, in which case:
sed -e '$d'
will delete the last line.
Using awk(1) or perl(1) would easily handle removing the newline
character from the last line in the more general case, e.g.:
awk '{if(NR>1)print l;l=$0};END{if(NR>=1)printf("%s",l);}'
perl -e '{$/="";$_=<>;chomp;print;}'
If one wants whatever to replace the last line, including replacing
the ending newline with nothing:
awk '{if(NR>1)print l;l=$0};END{if(NR>=1)printf("whatever");}'
perl -e '{$/="";$_=<>;chomp;s/[^\n]*$/whatever/o;print;}'
Back to top
Alan Connor
*nix forums Guru


Joined: 28 Feb 2005
Posts: 481

PostPosted: Sat Jun 10, 2006 10:27 pm    Post subject: CFAJ Forgery? (was: Self importance of U/L[nix] ?) Reply with quote

On comp.os.linux.misc, in <0tmrl3-e2t.ln1@xword.teksavvy.com>, "Chris F.A. Johnson" wrote:

Quote:
Path: text.usenetserver.com!atl-c01.usenetserver.com!news.usenetserver.com!news2.euro.net!news.mailgate.org!nntp.infostrada.it!area.cu.mi.it!news.newsland.it!eleonora.aioe.org!emma.aioe.org!aioe.org!xword.teksavvy.com!news

$ host xword.teksavvy.com
xword.teksavvy.com does not exist, try again

Only trolls post through aioe.org.
And only trolls falsify their path header.

Wait:

Quote:
From: "Chris F.A. Johnson" <cfajohnson@gmail.com

Anonymous and throwaway emailaddress.

Isn't there an SMTP server at teksavvy.com? What's the problem
with using that?

Is this really CFAJ?

Why would Chris feed this troll and use a crummy newsserver
like aioe and falsify his path header and use an anonymous and
throwaway email address?

Quote:
Newsgroups: comp.os.linux.misc
Subject: Re: Self importance of U/L[nix] ?
Date: Sat, 10 Jun 2006 16:33:04 -0400
Organization: Aioe.org NNTP Server
Lines: 56
Message-ID: <0tmrl3-e2t.ln1@xword.teksavvy.com
References: <pan.2006.06.09.22.08.43.231099@absamail.co.za
Reply-To: cfajohnson@gmail.com
NNTP-Posting-Host: rzptHS7pJmHxAyCc6QiecQ.user.aioe.org
X-Complaints-To: abuse@aioe.org

An utter waste of time. aioe is run by a troll, for trolls.

And I'm not convinced this was even posted through aioe anyway.
That is not what the first part of aioe's path header customarily
looks like.

Quote:
User-Agent: slrn/0.9.8.1 (Linux)
Xref: usenetserver.com comp.os.linux.misc:542622
X-Received-Date: Sat, 10 Jun 2006 16:33:09 EDT (text.usenetserver.com)

Alan

--
http://home.earthlink.net/~alanconnor/contact.html
Other URLs of possible interest in my headers.
Back to top
Chris F.A. Johnson
*nix forums Guru


Joined: 20 Feb 2005
Posts: 2268

PostPosted: Fri Jun 09, 2006 5:26 am    Post subject: Re: sed, remove last new line Reply with quote

On 2006-06-09, quarkLore wrote:
Quote:
Then why post in a newsgroup for the AWK programming language?
because I couldnt find a separate group for sed and saw other posts
related to sed, will try comp.unix.shell

and

sed '$,$s/^.*$/whatever/' test

removes the last "line" not the last new-line character.

Which is what you said you wanted:

Quote:
I have to use "sed and sed only" to either remove the last line or
if possible replace the last line with some character.


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Back to top
agarwal.prateek@gmail.com
*nix forums beginner


Joined: 01 Aug 2005
Posts: 3

PostPosted: Fri Jun 09, 2006 3:55 am    Post subject: Re: sed, remove last new line Reply with quote

Quote:
Then why post in a newsgroup for the AWK programming language?
because I couldnt find a separate group for sed and saw other posts

related to sed, will try comp.unix.shell

and

sed '$,$s/^.*$/whatever/' test

removes the last "line" not the last new-line character.
Back to top
Kenan Kalajdzic
*nix forums beginner


Joined: 29 Apr 2006
Posts: 31

PostPosted: Tue Jun 06, 2006 11:03 am    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Dave Farrance <DaveFarrance@omitthisyahooandthis.co.uk> wrote:
Quote:
Kenan Kalajdzic <kenan@cced.ba> wrote:

Try using 'ping' with the IP record route option:

ping -c 1 -R www.internic.net

then simply parse the output and extract the IP address of your router's
external interface. Note, however, that this method may not prove more
reliable than using HTTP. It can at least serve as an alternative.

Its position in the list depends on the number of routers (if any).
Displaying the whole list can be useful, but I don't see a way to
reliably extract the Internet-facing IP with a script.

You are right, it could be a challenge. However, in most cases you can
assume that the first public (routable) address in the list is the one
that is seen from the Internet.

--
Kenan Kalajdzic
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Tue Jun 06, 2006 10:58 am    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Kenan Kalajdzic <kenan@cced.ba> wrote:

Quote:
Try using 'ping' with the IP record route option:

ping -c 1 -R www.internic.net

then simply parse the output and extract the IP address of your router's
external interface. Note, however, that this method may not prove more
reliable than using HTTP. It can at least serve as an alternative.

Its position in the list depends on the number of routers (if any).
Displaying the whole list can be useful, but I don't see a way to
reliably extract the Internet-facing IP with a script.

--
Dave Farrance
Back to top
Kenan Kalajdzic
*nix forums beginner


Joined: 29 Apr 2006
Posts: 31

PostPosted: Mon Jun 05, 2006 9:05 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

In comp.unix.shell Dave Farrance <DaveFarrance@omitthisyahooandthis.co.uk> wrote:
Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

Other suggestions please?

Try using 'ping' with the IP record route option:

ping -c 1 -R www.internic.net

then simply parse the output and extract the IP address of your router's
external interface. Note, however, that this method may not prove more
reliable than using HTTP. It can at least serve as an alternative.

--
Kenan Kalajdzic
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 5:01 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

gazelle@xmission.xmission.com (Kenny McCormack) wrote:

Quote:
To the OP: If you can FTP to somewhere, try "quote stat".

Another interesting alternative. I guess this is a bit fragile because
it's dependent on the syntax of the current ftp for Linux.

#!/bin/bash
{
ftp -inuv <<eof
open ftp.proxad.net
user anonymous xx@xx.invalid
quote stat
quit
eof
} | awk '/ Connected to/{print $NF}'

--
Dave Farrance
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 3:09 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Bill Marcum <bmarcum@iglou.com> wrote:

Quote:
ifconfig

Yeah but I wanted the address as seen by the Internet rather than one
that might be assigned by a local network router.

--
Dave Farrance
Back to top
Kenny McCormack
*nix forums Guru


Joined: 24 Mar 2005
Posts: 657

PostPosted: Sun Jun 04, 2006 3:09 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

In article <em2bl3-je3.ln1@don.localnet>,
Bill Marcum <bmarcum@iglou.com> wrote:
Quote:
["Followup-To:" header set to comp.unix.shell.]
On Sun, 04 Jun 2006 10:57:16 GMT, Dave Farrance
DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.
....
ifconfig

Every question has an answer that is simple, obvious, straightforward, and ...

WRONG!

The whole point is that nowadays most machines are behind some kind of
NAT/firewall and so the "real" IP address is not the one that the
NIC is configured to.

To the OP: If you can FTP to somewhere, try "quote stat".
Back to top
William James
*nix forums Guru Wannabe


Joined: 01 Jul 2005
Posts: 229

PostPosted: Tue May 23, 2006 6:37 pm    Post subject: Re: print from a field to EOL Reply with quote

Chris F.A. Johnson wrote:
Quote:
On 2006-05-23, Harlan Grove wrote:
kpcamp wrote...
Ok I am trying to create a file from output field "3" and "9 to EOL"

while read line;do
ls -ltr "${line}" |awk {'print$3":"$9'} #Need to have $9 to EOL
done < $file

This really belongs in comp.unix.shell. Followup set.

while read line;do
ls -ltr "${line}"
done < "$file" | tr -s ' ' | cut -d ' ' -f3,9-

Or:

IFS='
'
ls -ltr $( cat "$file" ) | tr -s ' ' | cut -d ' ' -f3,9-

...

Since you're dealing with ls output, your fields are fixed length.

Modern versions of ls do not produce fixed-length fields; they
produce whitespace-separated fields. The actual width of any field
(except the last) is determined by the longest entry in the field.

Use substr to get the substring of $0 beginning at the first
character of $9 and print that rather than $9.



--
Chris F.A. Johnson, author <http://cfaj.freeshell.org
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

ruby -ane 'puts $F.values_at(2,8..-1).join(" ")'
Back to top
Kevin Collins
*nix forums Guru Wannabe


Joined: 11 Mar 2005
Posts: 216

PostPosted: Fri May 12, 2006 5:14 pm    Post subject: Re: Array Processing Please Help Reply with quote

In article <1147404466.382843.302380@j73g2000cwa.googlegroups.com>, BN wrote:
Quote:

Chris F.A. Johnson wrote:
On 2006-05-12, BN wrote:
Greetings Chris,

Here is the command:

set -A B $(echo "port $Port \n show post queue $Queue detail" |sp_ctrl
|egrep -i '^o\.| Redo log:| Log offset:|read rele
ased |hit count|Insert operations|Update operations|Delete
operations|at' |egrep -v 'Since|Operations')

I have multiple ports:
Port=" 1 2 3 4 5 6"
Each Port can have multiple Queue.

I run them in a double "for" loop to process all the queues for a given
port


here are 2 different outputs:

What do you want to do with that output?

Please note that Google groups is a front end to Usenet newsgroups.
Please read <http://cfaj.freeshell.org/google> for information on
posting correctly from Google.

When state != Idle

o.xyzacd Running 19936822 08-May-06 09:26:59 161
112
Last operation posted:
Redo log: 5491 Log offset: 101466192
INSERT in "SCOTT"."DEPT" at 05/11/06 21:45:03
Post state : Commit transaction
Activation Id : 4
Number of messages read released : 374712781
Insert operations : 7920317
Update operations : 3042954
Delete operations : 2110956
Key cache hit count : 924366
SQL cache hit count : 75 %

When State=Idle

o.xyzacd Running 19942311 08-May-06 09:26:59 2
0
Last operation posted:
Redo log: 5491 Log offset: 116285104
INSERT in "SCOTT"."EMPLOYEE" at 05/11/06 21:47:52
Post state : Idle
Activation Id : 4
Number of messages read released : 374718326
Insert operations : 7922286
Update operations : 3043820
Delete operations : 2111593
Key cache hit count : 924669
SQL cache hit count : 75 %


If you want I can send you the full script.

That would be good, as would quoting context when you reply.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

Greetings,

I apologize for not following the Usenet netiquette
Thank you for the link.

I insert the output into an Oracle Database:

Full Script:

HOST_NAME=$(hostname)
PORT_NUMBER="1 2 3 4 5 6 7 8"

SP_CTRL="/apps/opt/splex/product/4.0/bin/sp_ctrl"

echo "\nREM Host=$HOST_NAME Date:`date`\n" >/tmp/bn1.sql

for Port in $PORT_NUMBER
do
# Get the queue name for all the given ports
QUEUE=$(echo "port $Port \n qstatus " |$SP_CTRL |egrep -i Name
|cut -f5 -d" ")

# for each port and each queue get the stats and store them in the
Database
for Queue in ${QUEUE}
do
echo "\nREM Port=$Port Queue=$Queue \n" >>bn1.sql

set -A B $(echo "port $Port \n show post queue $Queue detail" |$SP_CTRL
|egrep -i '^o\.| Redo log:| Log offset:|re
ad released |hit count|Insert operations|Update operations|Delete
operations|at' |egrep -v 'Since|Operations')

if [ "${B[25]}" = "Idle" ]
then
cat <<EOF >>/tmp/bn1.sql

insert into scott.my_stats
(HOST_NAME, INSTANCE_NAME, QUEUE_NAME, PORT_NUMBER,
STATUS, OPERATIONS_POSTED, POST_START_DATE,
TOTAL, BACKLOG, REDO_LOG,
LOG_OFFSET, LAST_OPERATION_POSTED_DATE,
LAST_OPERATION,
INSERTS, UPDATES, DELETES, SQL_CACHE_HIT_PERCENT, LAST_COLLECTED)
values
('${HOST_NAME}', '$ORACLE_SID', '$Queue', $Port,
'${B[1]}', ${B[2]}, to_date('${B[3]} ${B[4]}','DD-MON-YY
hh24:mi:ss'),
${B[5]}, ${B[6]}, ${B[12]},
${B[15]}, to_date('${B[20]} ${B[21]}','MM/DD/YY hh24:mi:ss'),
'${B[16]} ${B[17]} ${B[18]} ${B[19]} ${B[20]} ${B[21]}',
${B[40]}, ${B[44]}, ${B[48]}, ${B[60]}, sysdate);
commit;
EOF
else
cat <<EOF >>/tmp/bn1.sql
insert into scott.my_stats
(HOST_NAME, INSTANCE_NAME, QUEUE_NAME, PORT_NUMBER,
STATUS, OPERATIONS_POSTED, POST_START_DATE,
TOTAL, BACKLOG, REDO_LOG,
LOG_OFFSET, LAST_OPERATION_POSTED_DATE,
LAST_OPERATION,
INSERTS, UPDATES, DELETES, SQL_CACHE_HIT_PERCENT, LAST_COLLECTED)
values
('${HOST_NAME}', '$ORACLE_SID', '$Queue', $Port,
'${B[1]}', ${B[2]}, to_date('${B[3]} ${B[4]}','DD-MON-YY
hh24:mi:ss'),
${B[5]}, ${B[6]}, ${B[12]},
${B[15]}, to_date('${B[20]} ${B[21]}','MM/DD/YY hh24:mi:ss'),
'${B[16]} ${B[17]} ${B[18]} ${B[19]} ${B[20]} ${B[21]}',
${B[41]}, ${B[45]}, ${B[49]}, ${B[61]}, sysdate);
commit;
EOF
fi
done
done

# Insert the values into the DB
echo "/ as sysdba \n @/tmp/bn1.sql"|sqlplus -S


Ok, I don't think anyone is going to re-write that script for you, but a much
better approach would be to do something along these lines:

echo "port $Port \n show post queue $Queue detail" |$SP_CTRL | while read line
do
case $line in
"Insert operations"*) ins_ops=${line##*: } ;;
"Update operations"*) upd_ops=${line##*: } ;;
"Delete operations"*) del_ops=${line##*: } ;;

... excercise in coding for YOU Smile
... add more logic to match all various values

esac
done

So, instead of relying on a "shifting" array, you grab specifically what you
want. Then, your INSERT statement can use the variables you define, and not
array elements, and you can eliminate the "if idle or not" logic...

Personally, I'd use perl or awk to parse this rather than ksh, but that's me :)

Kevin


--
Unix Guy Consulting, LLC
Unix and Linux Automation, Shell, Perl and CGI scripting
http://www.unix-guy.com
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 43 [637 Posts] Goto page:  1, 2, 3, ..., 41, 42, 43 Next
View previous topic :: View next topic
The time now is Tue Dec 02, 2008 5:48 am | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Function Pointer Sikandar C 3 Fri Jul 21, 2006 1:23 pm
No new posts Shortening URLs passing through a squid hierarchy Irvine, Doug - Resources Squid 0 Fri Jul 21, 2006 10:15 am
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts mod_rewrite to go from http to https and back sevans@bigskypenguin.com Apache 0 Fri Jul 21, 2006 5:12 am
No new posts Is there C/C++ corresponding function in Linux for Java's... xiebopublic@gmail.com apps 4 Fri Jul 21, 2006 3:22 am

Charity | Credit Cards | Mortgages | McDonalds | Credit Counseling
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.5031s ][ Queries: 16 (0.3464s) ][ GZIP on - Debug on ]