Perl script bad interpreter: Permission denied

April 11th, 2009

Something went wrong on my perl code which was working earlier before I made an upgrade from debian etch to lenny.
Here are the errors :
debian:/home/jojo/Desktop/pepesfile/drupal/mysite# ./index.cgi
bash: ./index.cgi: /usr/bin/perl: bad interpreter: Permission denied

On the apache log :
[error] [client 192.168.1.2] (13)Permission denied: exec of '/home/jojo/Desktop/pepesfile/drupal/mysite/index.cgi' failed

I’ve been tracing the error on it. I simply commanded the perl index.cgi on it but its fine. I suspect that there are ^M character which the DOS/Windows based text editor is giving on the first few lines of code but its fine when I try to view via VIM[1].

And then I’ve tried to look at the way the folder mysite/drupal mounted on my /etc/fstab
Here is my entry:
UUID=38c8ec02-5ef7-49fd-8607-78e4b2fe78c7 /home/jojo/Desktop/pepesfile ext3 auto,rw,user 0 0

I did add the exec on the column auto,rw,user and remounted the partition but its still not working :( .

Finally i’ve replaced that auto,rw,user,exec to defaults.

Ahh.. that solved my problem.

According to the fstab documentation here[2], “defaults uses the default options that are rw, suid, dev, exec, auto, nouser, and async.” I just need to type the other options and remove the nouser, but I’m glad fstab has this default. :D

[1] http://www.vim.org/
[2] http://www.tuxfiles.org/linuxhelp/fstab.html

A href = "#" with javascript event onclick issue on IE

February 4th, 2009

I have this kind of link on my code :


< a href = '#' onclick='javascript:window.open("http://somelocation.net/")'>somelocation </a>

The problem with this is that whenever this is clicked in a MS IE browser, both the original link and the new window is executed.
I was expecting that only the new window will be displayed and refresh. To solve this, i’ve changed my code to :


<href = '#' onclick='javascript:window.open("http://somelocation.net/");return false;' >
somelocation <a>

That solves the issue.

Perl: Appending array in a hash element

December 31st, 2008

My code :
push($parentmenu{$parentkey}{childlist},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);

Gives me this error.

Type of arg 1 to push must be array (not hash element) at ./test.cgi line 34, near “])”
Execution of ./test.cgi aborted due to compilation errors.

And it was just resolved by adding the @ and enclose it with {} – see the code below. I need an explanation though, but I’ll have to find the explanation later, for the meantime the solution just worked for my task.

push(@{$parentmenu{$parentkey}{childlist}},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);

Search and Replace text in all files in a folder and its subfolders

November 25th, 2008

Tip for those who are lazy enough to use vi and do :%/origstring/newstring/g on each files.

To replace all string occurence:

find /your/home/dir -name "*.txt" | xargs perl -pi -e 's/origstring/newstring/g'

To replace the first occurance:

find /your/home/dir -name "*.txt" | xargs perl -pi -e 's/origstring/newstring/'

To replace all files in a folder:

for arg in `ls -C1`; do perl -pi -e 's/origstring/newstring/g'; done;

« Older Entries   Newer Entries »