The UNIX Forums  



Forum Sponsor



Go Back   The UNIX Forums > Top Forums > Shell Programming and Scripting
Home Forums Register Rules & FAQDonate Members List Search Today's Posts Mark Forums Read

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Script using awk works only as super user

hi friends,

I am a new Sun Solaris 10 user. I have the following script

line=$(awk '{if(substr($0,1,1)!="#" &&
substr($0,1,1)!=";" &&
substr($0,1,1)!=" " &&
substr($0,1,1)!="/" &&
substr($0,1,1)!="*" &&
substr($0,1,1)!="\\" &&
length($0)!=0)
{print $0}
}' filename

This works fine when i login as super user but it does not work with other user and show error.

Do i need to change any enviornment variables please help

Thanks
Jithin.G
Reply With Quote
Forum Sponsor

  #2 (permalink)  
Old 1 Week Ago
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 3,030
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
I'm guessing there is an alias awk=nawk. Solaris awk is, um, defective, so advanced features require nawk - the new awk. As superuser, try
Code:
type awk
, then see what you get as another user from the same command.

In general you do not want to run around the system doing things in privileged mode. It's to easy to do something horrendous
Reply With Quote
  #3 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Thak you i will try and look into it
Reply With Quote
  #4 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
still the same

I am still geting the error

....ksh[line]: awk: not found

but with superuser it stll working
Reply With Quote
  #5 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: Jul 2006
Posts: 132
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Code:
Login as superuser:- 
type awk

then login as other user and add awk path to PATH variable in .profile and relogin
Reply With Quote
  #6 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
$PATH in super user has another component /usr/sbin
But which awk in both super user and user gives /usr/bin
I tried to change $PATH in *.profile file of user .it changes in file . But then again i checked the echo $PATH it shows the same earlier result.

The env command also shows earlier $PATH
Reply With Quote
  #7 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: Jul 2006
Posts: 132
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Code:
after changing $PATH in .profile you need to relogin
Reply With Quote
  #8 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
i restarted the system but it shows the same.....
The file content is changed But echo $PATH does not show any change
I changed the .profile file in /home/user/.profile file . Is this correct.
Reply With Quote
  #9 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: Jul 2006
Posts: 132
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
try like this

Code:
~/.profile
Reply With Quote
  #10 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: May 2008
Posts: 13
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
is shows permission denied.
Reply With Quote
  #11 (permalink)  
Old 1 Week Ago
Registered User
 
Join Date: Jul 2006
Posts: 132
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
put following entry in ur script

Code:
export PATH=${PATH}:/usr/sbin/
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sunsolaris shell script runs only as super user gjithin SUN Solaris 4 1 Week Ago 07:47 AM
Traffic Control Super Script 5.1.63 (Default branch) iBot Software Releases - RSS News 0 03-03-2008 03:10 PM
rsh as super user without password prompt TheMightyUrrrrf UNIX for Dummies Questions & Answers 1 02-13-2008 08:50 AM
reassigning key functions in super user mode lehcar511 UNIX for Advanced & Expert Users 5 06-19-2003 11:03 AM
FTP as Super User fbavent UNIX for Dummies Questions & Answers 3 05-22-2002 10:49 PM


web tracker

All times are GMT -5. The time now is 11:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
UNIX Forum Content Copyright ©1993-2008 SilkRoad Asia All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0