LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Bash scripts not working (https://www.linuxquestions.org/questions/linux-server-73/bash-scripts-not-working-4175464957/)

gopkris2000 06-06-2013 06:01 AM

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.

druuna 06-06-2013 06:13 AM

Quote:

Originally Posted by gopkris2000 (Post 4966507)
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.

gopkris2000 06-07-2013 03:49 AM

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||

pan64 06-07-2013 04:19 AM

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)


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