This is a script that I, this unix forum and stackoverflow come up with. I would like to get some feedback about it and improve it little bit if possible for even more readability and better working. OR get some shaming hilarious opinion.
Quote:
What this script does?
It checks whether this Script is ran with Bash shell.
If it did not, the notice will be echo'ed.
And the Script rerun with Bash.
Later:
It will check whether this Script is ran by the User that can execute Sudo directly or will be promped for a password.
The notice will be echo'ed.
Little bit more Later:
It will check if the User that executes this Script ran the Script with Sudo.
If Not, this script will be re-run with Sudo and Bash.
Not everyone has readlink. You can check the SHELL variable instead, it's quite standard.
Use [[ "$VAR1" == "value" ]] as single-equals and single square-braces are now archaic.
Automatically rerunning it with BASH is begging for an infinite loop if anything weird happens. You also didn't check if that exec failed.
Error messages should go to stderr, a la
Otherwise, people may find big flat error messages in their flatfiles whenever they redirect the output.
You don't need to and probably shouldn't be checking the text output of sudo -- just get its return value. There's also no reason to use a sub-shell, or a sub-sub-shell within that sub-shell. You can put it right into the if-statement as if it belongs there, which it does, with an ! in front to invert the return value.
hi guys
we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Hi guys,
I am sending the script i created..plzzz check it correct if any mistakes...:).
Plz reply early by today..
here i want to find the files based on date , if files are avaliable i want to send a mail to the user. here there are a total of 43 files. they are constant.
Here is... (0 Replies)
Hi,
I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop.
I am using RHEL 5.2 (2 Replies)
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
please check this script and let me know.wher eis the issue.
#!/bin/ksh
set -A logs AAA BB CCC DDD EE FFF
set -A ltime 7 60 7 7 7 60
set i=1
while } ]
do
find /home/logs -name "*"\${logs}"\*.log" -mtime ${l
time} -type f -ls
let i=$i+1
done (3 Replies)
I have written the below script to determine whether a string is palindrome or not ?
But its not working, any help to debug it ?
I am new to this forum but when I searched for my question, I found that many people refused to answer this question thinking that its Homework question, Therefore I... (2 Replies)
I want to create an automated script which is called by another maually executed script.
The condition is that the no one should be able to manually execute the automated script.
The automated script can be on the same machine or it can be on a remote machine.
Can any one suggest a check in the... (1 Reply)
I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit.
Logically, I'm looking for the best way to approach this
Thanks for any assistance in advance.
Note: I'm using a C shell and... (2 Replies)
I want develop a script which should also check validity of netmask.
e.g.
/etc/netmasks
10.15.20.30 255.255.255.224
How can I check which IP adresses are valid for this netmask?
I think the best is use logical operations.
224 is 1 1 1 0 0 0 0 0
so is valid from 10.15.20.31... (2 Replies)