Linux is good~ Always having permission problem. Always stopping me from making things work. Damn. Apache, which is the httpd service. Due to the fact that execution of bash script is done by thr "root" account, user Apache, have no permission to do it.
Fix the problem~
Problem is solved...
By cheating... Damn... Using the command, "system('echo "ROOT PASSWORD" | sudo -u root -S COMMAND')"; will trigger the necessary access needed to run iwlist.
Currently, the script for bringing up AP and WIFI is done and the NAT is done. The AP and WIFI is working fine, just that there is a need to do up a script for WIFI scanning. All in all is good.
There is also a shutdown script for AP and WIFI for the purpose of flushing the whole operation.
P.S. This is part of my progression journal. Sorry for those who is following the blog... =p
Here is some bash script troubleshooting technique that can be very useful when applied correctly.
Block comment for bash script in vi editor
In vi editor, comment from line n to m
<ESC>
:n,ms/^/#/
From line n to m substitute line start (^) with # sign
To remove comment
<ESC>
:n,ms/^#//
From line n to m substitute line start (^) followed by # with nothing //
Almost universal with /bin/bash for vi editor
There seems to be a problem... How are we to determine what line is what line... Count one by one? That's nuts~! But, there is a solution...
vi / vim editor does show line number
To display line numbers along the left side of the editor, type in the following command
<ESC>
:set number OR :set nu
To undo the line numbers
<ESC>
:set nu! OR :set number!
The above is just a one time thing. To make a permanent change for set number
Terminal#vi ~/.vimrc
In vi/vim editor
set number
Save and exit
Note: if you are curious on where is the file located, it may not be there. So just create the file and where will follow. Note of note: Only the user profile you create/edit the file will have the change.