unable to execute my file week4prog1Rebecca.scr, what is wrong?
I need help. So far I am not doing as good as I would like in class. I am just not finding the answers I look for to accomplish the right output.
Here is my file. I need to know how to execute this file. Any help will be greatly appreciated. #!/bin/bash count=1 echo "start of the program" while [ $count -le 10 ] do echo "Loop #$count" sleep 10 count=$[ count + 1] echo "end of the program" done Every command that I have found give me an error similar to this one bash: run: command not found |
Try executing your program with
Code:
./week4prog1Rebecca.scr Code:
chmod 755 week4prog1Rebecca.scr With this naming convention, you can use the make utility to, uh, make your program executable (and without the .sh extension): Code:
make week4prog1Rebecca Code:
./week4prog1Rebecca Hope this helps some. |
please explain the make command - not understanding
Ok, I have created my file again thanks to my school site that doesn't save anything I have done. I changed the permissions so it would execute but when I do the make command this is the error I am receiving.
make week4prog1Rebecca.scr make: Nothing to be done for `week4prog1Rebecca.scr'. [Student@localhost Rebecca]$ do I need to rename the .scr to a .sh? |
try this:
Code:
mv week4prog1Rebecca.scr week4prog1Rebecca.sh Code:
mv week4prog1Rebecca.scr week4prog1Rebecca.sh |
The make command suggested by tronayne is an alternative way to give executable permissions to the file (but it makes a copy of the original file without extension). Keep it simple and do this:
Code:
chmod +x week4prog1Rebecca.scr Code:
./week4prog1Rebecca.scr Quote:
|
Thank you, thank you and thank you.
although I found a mistake in my program I think. I did the mv week4prog1Rebecca.scr week4prog1Rebecca.sh then the chmod +x week4prog1Rebecca.sh (I first change mod was to the .scr file which didn't work) then ran ./week4prog1Rebecca.scr and that didn't work so I changed it to ./week4prog1Rebecca.sh and it executed the file.....YIPPPIEEEEEE now here is a twist to the program. I am sorry I keep asking for help but just don't understand all these commands and trying to find help is difficult. I have to add this: Modify the program to add a trap for SIGINT and SIGTERM. save the script and this time run the script in the background, use the jobs command to display a list of the jobs currently running. find the process id of the script and kill the job (I think I have the commands for this) check to see if you get the trap message run the scrip again using the at command to schedule the job in the future. Wait for the job to run to make sure it executes. |
Quote:
There are naming conventions that are worth your time to follow; e.g.,
The key phrase is "source code." Although many folks will retain the .sh extension on a shell program (and, consequently, will force anyone using that program to type prog.sh), the way Linux is intended to work is that all you need to do is type the name of a program -- no extensions -- and it'll go to work. Source code is kept separate from executable. Why it's a good idea to do this is really quite simple -- if you write a program (in any of the many languages available to you), chances are that as time goes on you're going to have a larger and larger collection of programs. If you keep your source code separate from the executable, you can easily edit the source without disturbing a program that may be in use by number of folks. That way, you can add features and test your changes without causing any problems until you're ready to "go live" with whatever changes you've made in the source. What the make utility does is take your source code and turn it into an executable; essentially, as colucix says, make simply copies a shell program source file, eliminating the .sh extension and changes the mode of the copy to make it executable. So, in your case, you would have two files, week4prog1Rebecca.sh (the source) and week4prog1Rebecca (the executable) -- you would simply enter (type) ./week4prog1Rebecca and hit the enter key to run it. If you were to edit week4prog1Rebecca.sh you would simply Code:
make week4prog1Rebecca Now, make does not simply copy with other languages, notably C and its derivatives, what it does with a C program is compile it to a binary executable; you start with prog.c, execute make prog, and you wind up with an executable prog (see the idea? source to executable with no extension?). For now, don't worry about those details, just bear mind the naming convention and remember that there's a tool, make, that makes it a little easier for you. As time goes on, you'll become familiar with the make utility -- it's a great tool that makes you life much, much easier and all you have to do is stick with a few conventions to get a great deal of work done with minimal effort (well, less that otherwise would be the case, say). A couple of other things to keep in mind, particularly if you're coming from a Windows background: no spaces in file names (ever); back slants (\) are not the same thing as slashes (/); it's directory, not folder; file name don't need to be a sentence, but do need to make sense. Best of luck with all of this. Hope this helps some. |
I need more help. I am supposed to do the following changes to the file I created earlier and hopefully it will run the way it should.
Here are the requirements - I ask because I am not finding how to make the modifications to my file. I have to add this: Modify the program to add a trap for SIGINT and SIGTERM. save the script and this time run the script in the background, use the jobs command to display a list of the jobs currently running. find the process id of the script and kill the job (I think I have the commands for this) check to see if you get the trap message run the scrip again using the at command to schedule the job in the future. Wait for the job to run to make sure it executes. |
All times are GMT -5. The time now is 04:27 AM. |