Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions created don't seem to work 3

Status
Not open for further replies.

jdespres

MIS
Aug 4, 1999
230
0
0
US
I have created the following functions and have added them to .profile: [ksh]

jobsfor () {bpdbjobs | grep "^ *$1"}
driveson () {vmoprcmd -h $1}
errorson () {bperror -U -problems -client $1}
getallservers () {grep "^SERVER " /usr/openv/netbackup/bp.conf |/usr/bin/awk '{print $3}'}
getallclients () {bpclclients -allunique -noheader | awk '{print $3}'}
getallpolicies () {bpcllist -allclasses -L | grep "Policy Name:" | sed 's/Policy Name: //'}
getallpools () {vmpool -listall | grep "pool name:" | awk '{print $3}'}
clientconfig () {bpgetconfig -M $1}

The functions where I have added sed & awk do not work...

When I login I get the following messages:

awk: syntax error near line 1
awk: bailing out near line 1
awk: syntax error near line 1
awk: bailing out near line 1
sed: command garbled: s/Policy Name: //}
awk: syntax error near line 1
awk: bailing out near line 1

These commands by themselves work....

Thanks....

Joe Despres

 
Enclose the awk and sed programs by double quotes if you want to include shell variables/parameters

getallservers () {grep "^SERVER " /usr/openv/netbackup/bp.conf |/usr/bin/awk "{print $3}"}


Or temporarily stop the single quotes

getallservers () {grep "^SERVER " /usr/openv/netbackup/bp.conf |/usr/bin/awk '{print '$3'}'}


HTH,

p5wizard
 
Hey P5wizard....

I tried what you mentioned....

Still having issues..

 
In all your function definitions, you may try this:
jobsfor () {[highlight] [/highlight]bpdbjobs | grep "^ *$1"[highlight]; [/highlight]}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Tried that last one....

getting the following:

.profile[38]: syntax error: `}' unexpected
 
On my AIX system, it gets really cranky when the opening { and closing } for functions are on the same line.

I defined the function like this:

getallservers () {^Jgrep "^SERVER " /usr/openv/netbackup/bp.conf |/usr/bin/awk '{print $3}'^J}

and it worked just fine.

Note: To enter the control J, when in edit/insert mode type a Control V followed by a Control J. If you did it correctly, you should see ^J on the screen. Additional verification - if you move your cursor over it, it should jump the ^ and J as 1 character.
 
Hi,

You can put all your functions in the file .kshrc located in the home directory of the user ( create it if it does not exist).
add the following line to the .profile file of the user
Code:
ENV=.kshrc
 
Solaris was cranky as well....

This works:

getallservers () {
grep "^SERVER " /usr/openv/netbackup/bp.conf |awk '{print $3}';}

I was hoping on getting my cake and eat it to...

But this is better than nothing!

Thanks!

Joe Despres
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top