LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 02-16-2012, 09:04 AM   #1
kalyanilinux
LQ Newbie
 
Registered: Jan 2012
Posts: 9

Rep: Reputation: Disabled
Question disk quotas shell script


Hello.. I wrote the following shell script to run disk quotas for assigning limits to users. I need to know the partition which the user has created and mount it. So i copied the partitions (which will be displayed after running fdisk -l) and separted the last line from it and cut the required partition name from it. Then this should be passed to the next line (using mount). Here I am facing the problem.. It is returning the error "device not found", that means the variable "$part" is not giving the partition name..

The following is my code:
Code:
VSIZE=100m;

fdisk /dev/sda >/dev/null 2>&1 <<EOF
n
p
3

+${VSIZE}M
w
EOF

partprobe /dev/sda

fdisk -l > file1

awk 'NF{s=$0}END{print s}' file1 > file2

part=(`cut -c "1 2 3 4 5 6 7 8 9 10" file2`)

mkfs.ext3 $part

mkdir /var/likes

mount $part /var/likes

chmod 777 /var/likes

quotacheck -cugv /var/likes

quotaon $part

setquota -u kal 2 3 4 5 -a $part
 
Old 02-16-2012, 02:39 PM   #2
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
I'd advise you to put a
Quote:
echo "$part"
line in the script to see what it is actually returning.The you can fix from there.
 
Old 02-16-2012, 10:35 PM   #3
kalyanilinux
LQ Newbie
 
Registered: Jan 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks for ur reply.I tried it,it is printing required value ( partition name) itself.But its not working in mount statement
 
Old 02-16-2012, 10:51 PM   #4
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
I mean echo $part to see what is actually being printed after the
Quote:
part=(`cut -c "1 2 3 4 5 6 7 8 9 10" file2`)

This command doesnt seem to be working....I thing it should be
Quote:
cat file2 | cut
depending on what you wanna do..
 
Old 02-16-2012, 10:54 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try
Code:
set -xv
as the first line
 
Old 02-16-2012, 11:09 PM   #6
kalyanilinux
LQ Newbie
 
Registered: Jan 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
@cbtshare
even this
Quote:
cat file2 | cut
is also not working fine
 
Old 02-16-2012, 11:13 PM   #7
kalyanilinux
LQ Newbie
 
Registered: Jan 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
@Chris
what is meant by
Quote:
set -xv
 
Old 02-16-2012, 11:23 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try it & see

Basically its a form of debugging; it shows you the before and after version (inc results) of parsing each line.
A key tool for fixing shell scripts.

http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 02-17-2012, 12:04 AM   #9
kalyanilinux
LQ Newbie
 
Registered: Jan 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
@chris
Thank you.. Ya it's debugging.. but what is the solution to solve the problem in code??
 
  


Reply

Tags
shell scripting



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
how to write shell script for dc3dd disk copying utility? mdfakkeer Linux - Software 6 04-18-2010 10:11 AM
Disk Quotas aniketgore Linux - Newbie 1 01-13-2008 08:17 AM
Setting disk quotas in a script JohnE1 Linux - Enterprise 2 06-27-2007 05:05 PM
disk quotas johnnycash Linux - General 1 03-16-2004 08:12 AM
disk quotas skeletal29 Linux - General 1 10-13-2002 04:42 PM

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

All times are GMT -5. The time now is 09:23 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