LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-06-2013, 06:01 AM   #1
gopkris2000
LQ Newbie
 
Registered: Sep 2006
Posts: 17

Rep: Reputation: 0
Bash scripts not working


I have used few bash script in my centos 6.4 server which is working fine.

but its not executing properly in cloudlinux kernel.

Bash version is different on both server.


example

working fine in centos 6
qt=$(quota -v $user | grep -v quotas | grep -v blocks | awk '{total+=$2} END {print total/1024}')

But this is not working in cloudlinux.
 
Old 06-06-2013, 06:13 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by gopkris2000 View Post
I have used few bash script in my centos 6.4 server which is working fine.

but its not executing properly in cloudlinux kernel.

Bash version is different on both server.

example

working fine in centos 6
qt=$(quota -v $user | grep -v quotas | grep -v blocks | awk '{total+=$2} END {print total/1024}')
not executing properly doesn't tell us anything.....

- error messages?
- no output?
- unexpected output?

I don't see anything wrong with the command shown. It could be done simpler/more elegant, but that's not the issue at hand.
 
Old 06-07-2013, 03:49 AM   #3
gopkris2000
LQ Newbie
 
Registered: Sep 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for your reply... I received unexpected output..

This once is correct
quota -v $user | grep -v quotas | grep -v blocks | awk '{total+=$2} END {print total/1024}'
user1 78||
user2 23||

But same command does not fetch user quota here
quota -v $user | grep -v quotas | grep -v blocks | awk '{total+=$2} END {print total/1024}'

user1 1000||
user2 1000||
 
Old 06-07-2013, 04:19 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
just execute the command quota and check if it has the same output format.
Do not use grep|grep|awk chain or similar, it can be implemented in one:
Code:
quota -v $user | awk '/quotas/{next}/blocks/{next}{total+=$2} END {print total/1024}'
(not tested)
 
  


Reply



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
LXer: Python Scripts as a Replacement for Bash Utility Scripts LXer Syndicated Linux News 1 01-17-2013 08:08 AM
How to get some bash scripts into a simple bash script with some echo and if statement. y0_gesh Programming 3 03-01-2012 09:46 AM
[SOLVED] Finding bugs in bash scripts, Analyis tool for bash traene Programming 2 10-31-2009 11:42 AM
Old Bash scripts not working KeenAs Programming 2 05-29-2009 07:55 AM
Bash scripts not working anticuchos Linux - Newbie 5 09-25-2005 09:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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