Sorry for a delayed response. I have not yet tried the code as I have been able to narrow down the problem cause. However the solution to the problem is a quick reboot of router.
However I appreciate all your help and efforts.
Thanks!
---------- Post updated at 09:23 AM ---------- Previous update was at 08:58 AM ----------
Quote:
Originally Posted by bakunin
In fact there are some problems with your code, but overall it looks quite OK. Lacking the tools you work with i cannot test it, though, so some general remarks is all the help i can give you.
Basically, this is a good attempt at enhancing runtime security, but: either "asterisk" is already within the PATH, then your statement would be superfluous, or it is not - would your statement help that in any way?
The answer is: no. Most binaries in Unix have fixed places anyway, so your "asterisk" binary might always reside in "/usr/bin/asterisk" or so. If this is not the case and you really need to find out where it is, then your script should react in some way if it is not to be found. And, by the way: NEVER USE BACKTICKS! POSIX process substitution is done with "$(...)". Having said this, consider the following:
Generally you should strive to use as few commands as possible, because every "fork()" system call is expensive. I do not know the output you are trying to check here, but i suppose it is "Status" and "OK" on the same line:
Furthermore, you should ALWAYS quote your string variables. If "$asteriskbin" contains a space (this would be a legal filename in Unix) your commadn would not work any more. The following is a suggestion as to how this is done easier. Maybe you have to adjust the regular expression in "grep" if the output is not like i supposed it to be:
Another this is to try to work strictly typed, even if the shell is not requiring it. If you want to create an integer variable, then create one explicitly:
The following is a common misconception related to that:
"test" (and its built-in sibling "[[") is strictly distinguishing between string comparisons and integer comparisons. "==" is an operator for strings only. Because you want to compare the integer values of "0" and "$checktrunk" you have to use the integer equivalent, which is "-eq":
I hope these pointers help. If you need more support just call back.
bakunin
Hi Bakunin,
Thanks for such an excellent explanation... has actually made me understand lot of things. I really appreciate the effort you have put through.
Your post has almost answered my next question... but just a small glitch.
always returns SIP trunk registration OK. even though I have put an incorrect SIP trunk name in the above checktrunk variable.
---------- Post updated at 09:56 AM ---------- Previous update was at 09:23 AM ----------
Surprised! this is working exactly the way i want it to work!
it returns SIP trunk registration failed. when the trunk is down and returns SIP trunk registration OK. otherwise.
Hi all!
Recently I've started to develop a small program that needs to
check for the arrival of files in a pre-determined directory.
I could use a timer to check for changes in this directory every n seconds.
Instead, what I'm really looking for is for some kind of notification mechanism... (1 Reply)
Hello All!
I am looking to build a monitoring script.
The script should always run as a system service of some type and should always check that a PHP script is running.
Maybe there is a way to assign a PHP script to a certain PID so that the monitor script that check for the PID in top... (4 Replies)
Hi there,
I've been looking all day, but could not find anything helpfull, so I hope you can help me.
When my system now starts up, the Xwindow is automaticly started and i get the log on screen (which is x screen 7 if I'm correct)
Now what I would like is on startup that instead of going to... (1 Reply)
Hi,
When I run the below script in UNIX it's throwing syntax errors. Actually it's a windows batch script. Could anyone change the below Windows Batch script to UNIX shell script...
Script:
REM :: File Name : Refresh_OTL.bat
REM :: Parameters : %1 - Region
REM :: : %2 - Cube Type
REM ::... (5 Replies)
Hello member's
I'm learning to script in the ksh environment on a Solaris Box.
I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows:
abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
#!/bin/sh
echo "Installing Java!!!"
cd /opt
echo "Want to give execute Permissions to java!!!"
chmod 755 jdk-6u7-linux-i586.bin
echo "Executing the jdk script"
./jdk-6u7-linux-i586.bin
This is the shell commands I am using...
I want to know how to give answer to yes and no automatically... (6 Replies)
I need a script which connects to vpn (asks for password) then when its connected starts a terminal connection to a specified ip address. Can somebody help me with this please?
Thank you in advance (0 Replies)
Hi all,
I have a simple script to check the CPU, Swap Memory and Hard Disk. But I can auto assign password in the script to automatic run it in crontab.
Everytime when I run this script, it require to insert password like the message below :
How can I solve this problem ? (2 Replies)
Discussion started by: cafecoc85
2 Replies
9. Post Here to Contact Site Administrators and Moderators
Hi All,
There are list of 4-5 .csv files which has 12 columns.In some cases one of the record is split into 2 records. What needs to be done is this split record has to be auto corrected and placed in the csv file.
Eg:
Let us consider sample.csv file and in normal conditions the file... (1 Reply)
Hi All,
There are list of 4-5 .csv files which has 12 columns.In some cases one of the record is split into 2 records. What needs to be done is this split record has to be auto corrected and placed in the csv file.
Eg:
Let us consider sample.csv file and in normal conditions the file would... (40 Replies)