- Wrong shebang path (the first line that starts with #!). This line tells which command/program to use for execution of the script.
- Incorrect permissions
Wednesday, May 31, 2006
Linux : crontab does not run perl scripts ?
Monday, May 22, 2006
Away for quite some time
I hope to be back for posting relevant content soon.
Friday, May 12, 2006
PHP : Website Security
PHP files that do database inserts or some other server-side tasks,
should not be accessible via a web browser. All files under Document
Root of a website are accessible by a web-browser. Document Root is
the directory on the server's filesystem. This directory contains the
files/web pages of the website.
To avoid direct access of your php files, you can keep them in a
directory that is not inside Document Root. These files can then be
included into your templates. For web applications, a configuration
file can be included in all files using a relative path. This
configuration file may contain variables like database connection
details and other configuration variables. Include for database
connection too, should reside outside the Document Root.
Variables of help
$_SERVER['DOCUMENT_ROOT']
This followed by relative path of your conf or include files can be
used on most servers.
On shared hosting server, Document Root is not defined for each
website (virtual host), so this variable shows the default value. In
such cases, you can use
dirname(__FILE__)
This gives you the value of the directory containing the file.
Thursday, May 04, 2006
Regular Expressions : Removing blank lines of a file in vi
Following is an ex editor command.
:1,$g/^$/d
Notes :
- ex editor commands start with a colon.
- 1,$ stands for first line to last line of the file
- g for global (look for the pattern following everywhere; do not stop after the first match)
- pattern to look for is placed inside two slashes (//)
- ^ is for start of line and $ for end of line. Here, there's nothing between the two so the pattern is used for an empty line
- d in the end is the command to delete matching lines.
:1,$g/^ *$/d
Note that there's an asterisk (*) after a space. An asterisk matches the character preceeding it zero or more times.
e.g.
/a*/ matches a,aa,aaa,any number of times.
/\d*/ mathes an integer. \d is for a digit.
Linux : music compositions with sox
I'd like to take it further and add functionality which will allow merging of wav files with sox command that comes with linux distributions. This will allow composer to download his composition in wave format and hear it ! This will require reading the text file and mergin the sound files in the same order. This should be possible with a script (perl/php ?).
I'll soon be collecting .wav recordings of all the basic tabla bols (aksharas) and give it a try. Your comments or ideas are welcome.
Tuesday, May 02, 2006
Linux : date command
date
# This prints the current date. Something of this form - "Tue Jan 31 12:16:53 IST 2006"
date +%d
# prints current day of the month
Following examples illustrate getting time related information of a day/date other than the current date
date --date="3 days ago"
# prints date that was 3 days ago
Try these too !
date --date="last Sunday"
date --date="next Sunday"
date --date="Jan 26, 2004" +%a
# prints Day of the week on Jan 26, 2004
Setting the system date. You need to have admin privileges to use --set option.
date --set='+10 minutes'
# Takes system clock forwad by 10 minutes.