Linux Script

Hello I have an command below:
nas_quotas -edit -user -fs usrfs1 -block 0:0 -inode 0:0 37022

The last 5 digts is a userID that basicly 0 the qutoa on a share. I have a list of this ID in a text file. I wrote the below command in a .sh file to excute and read the text file to add the user ID into the command. This loops throught  making the changes to the user.
.sh command:

while read line; do     
echo removing user $line # or whaterver you want to do with the $line variable
nas_quotas -edit -user -fs usrfs1 -block 0:0 -inode 0:0 $line
done < userid.txt

Open in new window

when I run the comand in the bat file this is what I get:

Warning 17716809848: server_2: NIS Error:  UNAME= 37023
Warning 17716809848: server_2: NIS Error:  UNAME= 37024
Warning 17716809848: server_2: NIS Error:  UNAME= 37026
Warning 17716809848: server_2: NIS Error:  UNAME= 37027
Warning 17716809848: server_2: NIS Error:  UNAME= 37028
Warning 17716809848: server_2: NIS Error:  UNAME= 37029
Warning 17716809848: server_2: NIS Error:  UNAME= 37030

The command work when I do one at a time, but its thosands that I have to do.

Thanks in advanced.
karephreIT Specialist (Server Management)Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan SpringerCommented:
The first line of your script should be :

cat <filename> |while read line

not 'while read line'

and replace <filename> with the correct /path/to/filename
The structure

    while read line;do
    done < userid.txt

is a reasonable way of specifying the command (and avoids a useless "cat").

Does userid.txt *only* contain the user names, one per line?  Are there any other characters on the line?

Has the file been transferred form Windows?  Run:

    od -c userid.txt | head

to see the actual characters in the file.  You should see the name, with no spaces either side of it, and with "\n" separating the names.  If you see "\r \n" you have a DOS format file.  If you do, then one option is:

tr -d '\015' < userid.txt | while read line; do
    nas_quotas -edit -user -fs usrfs1 -block 0:0 -inode 0:0 $line

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karephreIT Specialist (Server Management)Author Commented:
Hello Thanks for your advice. I did transfer it from a windows system with psftp. I will try your advance tomorrow once I arrive to work, and update with the results.

karephreIT Specialist (Server Management)Author Commented:

Your post lead me to the right direction. the od-c did show me dos format in the file, and I tried your secomand, but it did not formate. Then I found this command:

dos2unix <filename>

Ran it, then ran my .sh and worked!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.