ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
There is less than 12 hours left to vote in the 2015 LinuxQuestions.org Members Choice Awards. Click here to go to the polls. Vote now and make sure your voice is heard!
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
First, your question should have been posted in the "Programming" forum, not here.
Second, bash, as a scripting language, executes a sequence of commands which, in principal, you could run from a command prompt.
So, the answer to your question is another question: What command(s) would you issue from a terminal (command-prompt window) to "move to a point?"
Note that, in your question, you have not told us what you want "moved" to the "point," nor have you told us what you want to do when it "gets" to the point.
Now I know that the above is not helpful, for which I apologize, so here's a guess: You're looking for a window manipulation method, and the "points" of which you speak are coordinates inside the window. If that's what you're look to accomplish from a command line, you need to be looking at a windowing system. For example, you could install the tool control language (tcl) and wish, and then use those commands to create and manipulate windows.
Please don't do that; I've reported your thread to be moved to Programming. In future, if you've posted in the wrong place, just use the "Report" button to ask the moderators to move the thread for you.
As far as your original post though, here is an excerpt from one of my scripts:
read -p " place wlan0 into monitor mode? (yn) " answer
case $answer in
[yY]* ) echo -e "\033[34m ---placing wlan0 into monitor mode..."
airmon-ng start wlan0
[nN]* ) break;;
I used that to ask a general yes or no question, and if Y or y is inputted, it executes airmon-ng. The tutorial that MensaWater posted is a good one to read and to understand and learn how to do bash scripting.
im writing a bash script to dip my toe into programming but i need syntax help
echo "do you accept (Y/N)"
if y continue
if n exit
else go to x point [or] (else ignore)
what bash commands would i use to make this happen
You don't use goto's in bash scripting.
this is run if "command" was successful
this is run if the first command failed but this one succeeded
this is run if none of the commands succeeded
this is run over and over while "command" is successful. "command" is run before every iteration.
for myvar in list
this code is run for every item of the list, where $myvar contains the current item
The "test" command (or it's alias, "[") is often used for if and while conditions. See "man test" for more info.
another approach is functions; Putting the stuff together would be
while [[ "$valid" != "no" ]]
echo -n "Can you give a valid answer? [y/n]: "
case $answer in
[yY]*) valid="yes"; break;
[nN]*) valid="yes"; break;
*) valid="no"; break;
There are a few things to keep in mind:
- most likely the answer given in $answer is not carried over to the main part of your script; This is because in some cases bash spawns a sub-shell. I generally use Korn shell (ksh) to overcome that problem.
- a function must exist prior to calling it; so your functions are at the top of your script, the "body" at the bottom.