Go to advanced search

by scrapheap
Mon Dec 23, 2013 10:53 am
Forum: Other programming languages
Topic: Apache2 and Perl cgi-bin
Replies: 3
Views: 3702

Re: Apache2 and Perl cgi-bin

Try dropping the quotes on the first line, so it looks like:

Code: Select all

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "== Perl_embed ==";
by scrapheap
Fri Dec 20, 2013 2:25 pm
Forum: Other programming languages
Topic: [SOLVED]Measure execution time inside Shell script
Replies: 2
Views: 2042

Re: Measure execution time inside Shell script

Sometimes the time command isn't present in the filesystem, instead some OSs choose to rely on bash's builtin in commands. Check if your shell script is set to use bash or something else? Specifically check the first line and if it says: #!/bin/sh Then change it to: #!/bin/bash and see if it makes a...
by scrapheap
Wed Sep 04, 2013 10:44 am
Forum: Other programming languages
Topic: bash: if file
Replies: 18
Views: 3919

Re: bash: if file

Find doesn't use locate's database of files, it will actually hit the filesystem. This gives you the advantage of it looking at the current state of the files and directories, but it does so at the cost of time (especially when checking a large file system over a USB connection). If you want get clo...
by scrapheap
Fri Jul 26, 2013 1:12 pm
Forum: Other programming languages
Topic: Installing CPAN modules
Replies: 4
Views: 6609

Re: Installing CPAN modules

To install LWP just use sudo apt-get install libwww-perl To install the other two you will probably have to use the CPAN module. Use perl -MCPAN -e'shell' to open a CPAN shell, let it auto configure if possible. Once you have the CPAN shell you can then install using install Weather::Underground and...
by scrapheap
Wed Jul 24, 2013 10:18 am
Forum: Other programming languages
Topic: Installing CPAN modules
Replies: 4
Views: 6609

Re: Installing CPAN modules

If you are still having trouble then the first two questions that spring to mind are Which OS are you using? Which module are you trying to install? Knowing the OS will help determine if everything required to build a module is present and the knowing which module you are trying to install will help...
by scrapheap
Thu Jul 18, 2013 11:55 am
Forum: C/C++
Topic: Coin Toss Simulator
Replies: 17
Views: 3308

Re: Coin Toss Simulator

Just stumbled across a post about the Raspberry Pi's hardware random number generator ( http://scruss.com/blog/2013/06/07/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator/ ), which could be a good solution to try. I suspect that its performance will be somewhere between /d...
by scrapheap
Thu Jul 11, 2013 10:13 am
Forum: C/C++
Topic: Coin Toss Simulator
Replies: 17
Views: 3308

Re: Coin Toss Simulator

Have you tried using /dev/urandom instead of /dev/random? /dev/random will block when your entropy pool is empty and so can cause slowness if repeated called. /dev/urandom won't block when the entropy pool is empty, but is theoretically predictable (though I have never seen anyone actually do so). F...
by scrapheap
Tue Jun 25, 2013 12:43 pm
Forum: C/C++
Topic: little problem with if statement
Replies: 4
Views: 1147

Re: little problem with if statement

nt.nti.nai.abtUid is an array and as such is a pointer unless you are using an offset (i.e. indexing into the array) or dereference it (combine the dereference with a cast to get the type of value you are looking for). Here's an example of dereferencing a cast of a similarly defined array. #include ...
by scrapheap
Tue Jun 11, 2013 8:41 am
Forum: General programming discussion
Topic: Grep help
Replies: 9
Views: 2902

Re: Grep help

Perl is great and I do use it pretty much every day, but for some tasks it is a bit overkill and I find it easier and quicker to just use grep, sed or awk. Especially if I am writing a shell script. Generally if all I am doing is looking for things then I use grep (usually with the -P option so that...
by scrapheap
Mon Jun 10, 2013 3:51 pm
Forum: General programming discussion
Topic: Grep help
Replies: 9
Views: 2902

Re: Grep help

If you are going to be using awk then you don't have to use grep, just tell awk what pattern you want to match first.

Code: Select all

awk '/Enc=WEP/ {print $1 " " $3}' wifi.txt
You could also use sed to filter the file as well.

Code: Select all

sed -e '/Enc=WEP/ !d' -e's/Enc=WEP //' wifi.txt
by scrapheap
Wed Jun 05, 2013 12:18 pm
Forum: Other programming languages
Topic: Perl and GPIO (?) issue/bug
Replies: 3
Views: 1503

Re: Perl and GPIO (?) issue/bug

Instead of chomp I tend strip off carriage returns and new lines with

Code: Select all

$lines=~s/[\r\n]+$//;
by scrapheap
Mon Apr 22, 2013 11:45 am
Forum: Other programming languages
Topic: How to include random questions into a bash script.
Replies: 3
Views: 1211

Re: How to include random questions into a bash script.

Picking random questions from an array in bash isn't actually that hard (assuming you have a version of bash that has support for arrays). Try the following code that defines two arrays (one for questions and one for answers) works out the length of the arrays and stores it in the QL variable. It th...
by scrapheap
Thu Apr 18, 2013 10:25 am
Forum: C/C++
Topic: C IDE/text editor for Wheezy
Replies: 18
Views: 20247

Re: C IDE/text editor for Wheezy

If you are willing to put the effort in to learning vim or emacs then the rewards can be great. Personally I use vim a lot (for C coding, Scripting, web development, mobile app development, etc) and while there have been times that I have had to learn something new about it to save my time and sanit...
by scrapheap
Wed Apr 17, 2013 4:21 pm
Forum: Other programming languages
Topic: Perl Modules from CPAN
Replies: 3
Views: 1727

Re: Perl Modules from CPAN

DateTime is great module and well worth using if you have any complex time based stuff to do, but for simply checking the machines local time you could just use the localtime (http://perldoc.perl.org/functions/localtime.html) function

Code: Select all

my ($sec,$min,$hour)=localtime();
print "$hour\n";
by scrapheap
Fri Mar 15, 2013 9:13 am
Forum: Other programming languages
Topic: Perl - Hangup ?
Replies: 2
Views: 851

Re: Perl - Hangup ?

A few questions that might help * What CPAN modules are you trying to install? * At what stage of installing from CPAN do you encounter it locking up? * Does the whole machine lock up or can you open another shell? * Does it lock up when installing Pure Perl modules or only when it requires some C c...
by scrapheap
Tue Mar 05, 2013 1:53 pm
Forum: C/C++
Topic: Create an output file in c
Replies: 16
Views: 12641

Re: Create an output file in c

thanks for the ctrl d correction. I was scratching my head on that one. Perhaps it was the old DEC VT100's(?) that used z. I believe that DOS/Windows uses ctrl+z to signify an end of file. Back in the days of DOS there were plenty of times when creating a small text file would require us to do some...
by scrapheap
Thu Feb 28, 2013 10:02 am
Forum: Other programming languages
Topic: Check networkconnection with Javascript
Replies: 3
Views: 932

Re: Check networkconnection with Javascript

navigator.onLine is known to lie on some browsers. If it is is false then you are pretty sure to be offline, if it is true then you may or may not be online (depending on the browser). A sensible thing to do after discovering that navigator.onLine is true would be to make a http request to known web...
by scrapheap
Tue Feb 26, 2013 11:03 am
Forum: General programming discussion
Topic: programming a frontend launcher program
Replies: 4
Views: 1444

Re: programming a frontend launcher program

Pretty much any scripting language would be suitable for this (BASH; Perl; Python; etc.). If you know one of them then use that. On the other hand, if you are looking to use this as a project to learn a language from then I would suggest Perl or Python (knowledge of either will put you in a good pos...
by scrapheap
Wed Feb 20, 2013 9:18 am
Forum: General programming discussion
Topic: Remote backup script
Replies: 2
Views: 985

Re: Remote backup script

Screen and nohup are useful commands but there will be times when you have a job running that you haven't started via screen or nohup and you don't want to have to restart to leave it running when you log off. If that is the case then you can disown your job. First push your job to the background (<...
by scrapheap
Wed Feb 13, 2013 5:24 pm
Forum: Raspbian
Topic: getting the udlfb module on the 3.6.11+ kernel
Replies: 0
Views: 780

getting the udlfb module on the 3.6.11+ kernel

I have the latest install of Raspbian and the udlfb module isn't included as standard and I have been trying to compile it from source but I can't seem to get a working udlfb module. I have picked up the kernel source from https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gz, extracted the ...

Go to advanced search