LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 03:16 PM   #16
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,451

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060

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, 04:08 PM   #17
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,451

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
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, 03:34 PM   #18
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,786

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
@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 08: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 08:27 AM
password less authentication from SunOS to HP-UX not working xxx_anuj_xxx Solaris / OpenSolaris 4 07-29-2009 11:10 AM
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 12:08 PM
SunOS 5.8 Retrieve the shell handle from another widget? fuzelogic Programming 1 03-08-2004 07:56 AM

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

All times are GMT -5. The time now is 04:19 PM.

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
Open Source Consulting | Domain Registration