ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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
#my first script
echo "Hello World!"
chmod 755 my_script
./my_script
echo $PATH
export PATH=$PATH:documents
mkdir bin
my_script
Where the line that says export PATH=$PATH: Is this where I put the path to my script in my documents?
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?
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.)
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.)
Thanks for enlightening me. I was unaware of 'pinfo bash'
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.
Last edited by Ztcoracat; 12-01-2012 at 07:10 PM.
Reason: Additional thought-
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
# /etc/cron.d/anacron: crontab entries for the anacron package
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
30 7 * * * root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
I have read this file several times but still do not understand how to write a shell script for rkhunter and chkrootkit that I would like an executable script to run. Otherwise I have been opening the terminal and running these applications manually.
Any suggestions?
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?
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.