Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
if you go to the terminal and run a command that gives you an error message and then
Code:
echo $?
it will return a 1. If the last command was successful is till return a 0. -eq is an evaluation for equals then you have the results if true the first thing || (or) is false the second
if you go to the terminal and run a command that gives you an error message and then
Code:
echo $?
it will return a 1. If the last command was successful is till return a 0. -eq is an evaluation for equals then you have the results if true the first thing || (or) is false the second
Thanks sydney...Thank you very much..Very clear description.I understood them all Thanks again
LOL is till should be it will, sorry, but I am happy you found it clear.
Hey sydney im new to Linux..And im going to do RHCSA in this month..I think you are a person that have a good linux knowledge. Can i found you on Fb or twitter? Or your mail address?
I have accepted your friends request. I have been studying for that test for a while and work with Red Hat every day. If you are new to Linux I would suggest either their classes or a ton of time on systems. I would be happy to help you, but this forum is probably your best bet on ways to find out stuff that is puzzling.
The line below doesn't backup the file to /home, it actually backs up both /www and /home to the tape drive. The stuff in /dev usually represent devices on the system. "st" means "Scsi Tape". The 0 means the first scsi tape.
Code:
tar -cvf /dev/st0 /www /home 2>/dev/null
The following line is, quite frankly, a mess. Why someone would write something convoluted like this, I'll never know.
The line above invokes the mail system to send email to vivek@nixcraft.co.in with subject line 'Backup status'.
Normally, the mail system will read the contents of the email from stdin (the keyboard). If you wanted to email he contents of a file (/tmp/mailbody.txt), you could have used this:
The "<<" is a special item called a "here document". It means, "I want you to redirect the input of this command from a file - Oh, and by the way, here is the content of the file."
The "END_OF_MAIL" is just a string that defines the start and end of the 'file' contents to be redirected into the command.
This is very useful as it obviates the need to create an intermediate file.
# The line below doesn't backup the file to /home, it actually backs up both /www and /home to the tape drive. The stuff in /dev usually represent devices on the system. "st" means "Scsi Tape". The 0 means the first scsi tape.
tar -cvf /dev/st0 /www /home 2>/dev/null
[ $? -eq 0 ] && status="Success!" || status="Failed!!!"
# the line above is, quite frankly, a mess. Why someone would write something convoluted like this, I'll never know.
# Here it is, rewritten to be more clear.
Code:
returnCode=$?
if [ $returnCode -eq 0 ]
then
status="Success!"
else
status="Failed!"
fi
mail -s 'Backup status' vivek@nixcraft.co.in<<END_OF_EMAIL
# the line above invokes the mail system to send email to vivek@nixcraft.co.in with subject line 'Backup status'.
# Normally, the mail system will read the contents of the email from stdin (the keyboard). If you wanted to email
# the contents of a file (/tmp/mailbody.txt), you could have used this:
mail -s 'Backup status' vivek@nixcraft.co.in </tmp/mailbody.txt
# The "<<" is a special item called a "here document". It means, "I want you to redirect the input of this command from a file.
# Oh, and by the way, here is the content of the file."
# The "END_OF_MAIL" is just a string that defines the start and end of the 'file' contents to be redirected into the command.
# This is very useful as it obviates the need to create an intermediate file.
Yep, I totally glazed over the dev path in that line. This is a much better explanation. Thanks,
The line below doesn't backup the file to /home, it actually backs up both /www and /home to the tape drive. The stuff in /dev usually represent devices on the system. "st" means "Scsi Tape". The 0 means the first scsi tape.
Code:
tar -cvf /dev/st0 /www /home 2>/dev/null
The following line is, quite frankly, a mess. Why someone would write something convoluted like this, I'll never know.
The line above invokes the mail system to send email to vivek@nixcraft.co.in with subject line 'Backup status'.
Normally, the mail system will read the contents of the email from stdin (the keyboard). If you wanted to email he contents of a file (/tmp/mailbody.txt), you could have used this:
The "<<" is a special item called a "here document". It means, "I want you to redirect the input of this command from a file - Oh, and by the way, here is the content of the file."
The "END_OF_MAIL" is just a string that defines the start and end of the 'file' contents to be redirected into the command.
This is very useful as it obviates the need to create an intermediate file.
Wow what a nice explanation...THanks alot mate.Anyway could you please explain me this little thing?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.