Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm creating a BASH script to make transitioning to different wireless networks easier. I want to make it so that when I ask the user a question and he inputs his answer that it will convert what he's inputed to lower case. That way if they accidentaly input a capital the script won't be messed up.
I'm also wondering if anyone knows how to make a BASH script that will show three dots (...) repeating over and over until a certain process finishes. I basically want them to be like when a program is loading and it shows the dots repeat until it finishes. This will make the script more animated.
If anyone can help me with either of these I would be greatly appreciated.
Or, you could pipe the user input through tolower, which will convert whatever it's given to lower case. The companion function is toupper, to convert to upper case.
Thanks for the input /bin/bash but it didn't work. I have a shell script called "apache_log_check" that just looks at the apache error_log and report anything it finds via mail command.
When I replace $PROCESS with the location of my script, I see no progress lines '...'. Can it display the progress of shell scripts?
thanks a lot guys. It works great. I still need to find toupper. I can't get a man page on it and I don't see it in YAST to install as well as syntax on google. any ideas? My next research is finding out how to change the color of text.
Originally posted by heema changing the text is not hard
this example changes the text to red
echo -e "\033[0;31mHelloo\033[0m"
but i cant remember the page that i got it from as the value 33 is red but i dont know the other colours
Yeah, I figured it out. I just need to figure out how to change the input to lower case with tolower. I don't see how to use that command anywhere in SuSE.
Originally posted by rootking thanks a lot guys. It works great. I still need to find toupper. I can't get a man page on it and I don't see it in YAST to install as well as syntax on google. any ideas? My next research is finding out how to change the color of text.
Coloring is done with ANSI codes, as commented above by others.
two ways to have the ANSI 'escape' character: echo -e "\033[0m" could do it (-e allowing escape codes,
or echo "^V<esc>[0m" (press Cntl-V followed by ESCAPE) to have it produce the same result.
Colors?
0 = default color
30 = black
31 = red
32 = green
33 = brown (or: dark yellow)
34 = blue
35 = magenta
36 = cyan
37 = grey
30;1 = dark grey (actually: bright black)
31;1 = bright red
32;1 = bright green
33;1 = yellow (actually: bright brown)
34;1 = bright blue
35;1 = bright magenta
36;1 = bright cyan
37;1 = white (actually: bright grey)
replace the thirty numbers to fourty numbers to change the background coloring
Check it out with:
Code:
for i in `seq 40 47`;do
for j in `seq 30 37`;do
echo -e "\033[${i};${j}mColor front=$j, back=$i\033[0m"
done
done
Coloring is done with ANSI codes, as commented above by others.
two ways to have the ANSI 'escape' character: echo -e "\033[0m" could do it (-e allowing escape codes,
or echo "^V<esc>[0m" (press Cntl-V followed by ESCAPE) to have it produce the same result.
Colors?
0 = default color
30 = black
31 = red
32 = green
33 = brown (or: dark yellow)
34 = blue
35 = magenta
36 = cyan
37 = grey
30;1 = dark grey (actually: bright black)
31;1 = bright red
32;1 = bright green
33;1 = yellow (actually: bright brown)
34;1 = bright blue
35;1 = bright magenta
36;1 = bright cyan
37;1 = white (actually: bright grey)
replace the thirty numbers to fourty numbers to change the background coloring
Check it out with:
Code:
for i in `seq 40 47`;do
for j in `seq 30 37`;do
echo -e "\033[${i};${j}mColor front=$j, back=$i\033[0m"
done
done
Alright, Thanks for your help. Here's what I need to do specifically with the tr section. I need to convert the input a user gives to lower case. Here is what I have and it's not working. I feel like the logic is correct but the syntax might not be. How can you help me.
Code:
read -p "Would you like to load one of these? [y/n] " QUEST1
QUEST2=echo -n $QUEST1 | `tr "A-Z" "a-z"`
if [ "$QUEST2" = y ];
then
# the rest of the script
I ask the user a question and take their response with the read command and place it in the form of the variable QUEST1. I then assign a new variable QUEST2 the output of QUEST1 turned into lower case. I finally have an if statement that takes the value they chose of "y" or "n" and carries out the rest of the command accordingly. What am I doing wrong here. Perhaps I don't need to use any of this tr stuff and there is a way to specify in my if statement to check for Y or y. This way it will cover the bases. I'm not sure if I can do an or with the if statement.
read -p "Would you like to load one of these? [y/n] " QUEST1
QUEST2=echo -n $QUEST1 | `tr "A-Z" "a-z"`
if [ "$QUEST2" = y ];
then
# the rest of the script
I see backticks with the tr command...
Try this and find the difference (look at the backticks):
Code:
read -p "Would you like to load one of these? [y/n] " QUEST1
QUEST2=`echo -n $QUEST1 | tr "A-Z" "a-z"`
if [ "$QUEST2" = y ];
then
# the rest of the script
When I replace $PROCESS with the location of my script, I see no progress lines '...'. Can it display the progress of shell scripts?
-twantrd
No not the way it is written. The pid of a shell script is the pid of the shell. So you may have several bash shells running and you would need to look through /proc to find the one that is running your script. One way to do it would be to use the $! variable. In bash $! refers to the last process put in the background. So you could modify the script like this to make it work:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.