First Script and bin directory
;)Hi:
This is my first script and I know it probably has errors but I am trying to understand. I used gedit to make it. I have read this article to help http://www.linuxcommand.org/wss0010.php Code:
#!/bin/bash ztcoracat/documents/my_script? And the line for mkdir bin; if I make a new directory is there only one bin that it will be dedicated to? Does my script have to be named 'my_script"? Can it be named my_firstscript1? The instructions say to move my script into my new bin directory. Where are new bin directories located? In the Home folder? |
Your script could look like this
Code:
#!/bin/bash Code:
chmod 755 my_script |
Quote:
How or where can I learn and read more to understand? I'm asking because I need to learn how to write a script for 2 cron jobs to run and I still don't understand even after reading all this that a moderator posted for me. I've read through all of this documentation and Bash scripting is still foreign to me. http://www.tldp.org/ http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.gnu.org/software/bash/manual/bashref.html http://www.webring.org/hub/linux?w=1...hat-linux;rd=1 I didn't read through the Advanced Bash Scripting Guides because I'm still struggling with basic scripting- Would going and learning Perl help me anymore in understanding Bash? What else can you recommend? |
Go to the Programming forum and look at the bash scripting questions and answers. Also, try the pinfo bash command for a useful on-line reference. (Depending on your distribution, you may need to install the pinfo command, or just use the older info command.) Often whilst I program a bash script, I keep the pinfo bash output in a tab on my terminal emulator so I can refer to it as needed.
You could also look at the scripts in /etc/cron.*/ to see how they are written. Consider asking the forum moderator(s) to move you thread into the Programming forum. (You can make the request by "reporting" your thread - there should be a button at the bottom of your first post.) |
Perl is a great language but it wouldn't help you much with bash.
Programming needs to be learned by doing it - and having exercises that are actual small (to start with) things you want programmed. |
Quote:
My distro is Debian 6.0.5 Stable Squeeze AMD 64bit- Reading through the Programming Forum is not helping but I just started so I will give it a chance. Thanks for the good advice. |
Quote:
I hope to find more exercises that are small that I can grasp- I'll check in my "The Debian Administrators Handbook" as there might be a few chapters that discuss Bash- |
I found these differnt entries for Bash after the hashbang and am wondering why is the command interpreter different when these are used?
#!bin/bash #!bin/sh #usr/bin/perl #!usr/awk I looked in etc/cron.d to learn from the file. It's output is: Code:
CRON.d Any suggestions? |
Quote:
These are different programs. And you're missing the first / after #! |
Quote:
Got it; like this: #!/bin/sh #!/bin/bash |
Moderator Response
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
|
Thanks; Onebuck!;)
|
Where in the script would I type my explanation of the purpose of the script?
For example: This script is for cron jobs to run rkhunter and chkrookit @ 8 o'clock p.m. every Friday to make certain that there are not any root kits on my system- Before or after the PATH? And where should the PATH start from the /usr/bin or etc/cron? |
Bash script or Terminal
Is this argument suitable for a script?
Quote:
|
Quote:
Is there anywhere else I could go to better understand scripting? And would learning C programming or C+ make Bash scripting make any more sense to me? |
All times are GMT -5. The time now is 10:28 AM. |