LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-25-2016, 04:16 PM   #16
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,246

Rep: Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573

Well the script in post#1 works on Solaris 10.
However there are some risks e.g. when the order of "df -h" would differ from "df -Pk" (though it never did in my tests).
I suggest the classic shell method: a while loop that reads the columns into distinct variables. Simple, efficient, safe.
Code:
df -kP |
while read fs x x x used x
do
  case $fs in /*)
    echo "File System $fs used space is $used"
  ;;
  esac
done
 
Old 10-25-2016, 05:08 PM   #17
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,246

Rep: Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573
Quote:
Originally Posted by hiten11 View Post
Hi I tried the above command but the execution of this command is not getting completed successfully and i have to explicitly press ctrl^c to kill the command
Perhaps even a simple
Code:
df -k
is hung on your Solaris system?
 
Old 11-19-2016, 04:34 PM   #18
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,768

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
@hiten11 A little late but please be aware LinuxQuestions has a dedicated Forum for Solaris related questions here.

In any case, note that there is a very simple way to make your original script working almost as is on Solaris. Just add the following line as first instruction, just after the shebang:

Code:
PATH=$(getconf PATH):$PATH
and that's it. This command is setting the PATH for the shell and other commands to run POSIX compliant utilities. Under Solaris, POSIX compliant utilities are not necessarily the default ones. After setting the PATH, the df and awk commands will behave the way you expect.

You script would still be non portable as it uses bashisms but this is not a problem as Solaris has been bundling bash since more than a decade.

Last edited by jlliagre; 11-20-2016 at 09:21 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getopts script not working in redhat sh (works in sunos sh) khandu Programming 1 02-16-2012 09:27 AM
password less authentication from SunOS to HP-UX not working xxx_anuj_xxx Solaris / OpenSolaris 4 07-29-2009 12:10 PM
Shell scripts migration from SunOS 5.9 to Red Hat Linux Advanced Server 4.0 64-bit devenr_2000 Linux - Newbie 1 11-13-2007 01:08 PM
SunOS 5.8 Retrieve the shell handle from another widget? fuzelogic Programming 1 03-08-2004 08:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration