FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » randomly sorting files in php
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
randomly sorting files in php [message #180578] Fri, 01 March 2013 01:49 Go to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
Hello ng,

I've got a working localhost and a couple php scripts that run so far,
so I wanted to see what types of things I can do and cannot do. This is
by no means clear to me to me now.

What I have is a collection of my own music files that I have put in the
path of where localhost is looking for things; with my default install,
that is /var/www.

I wrote a bash script to export the files off my mp3 player, because
neither my gf nor I who bought these things can figure how to make them
play randomly. Yes we have achieved a certain age, where determination
makes up for a lot.

$ cat music1.sh
#!/bin/bash

set -e
FROM='CCE0-705F'
DIR='music1'
mkdir -p $DIR
cp $FROM/*.wma $DIR/
cp $FROM/*.mp3 $DIR/
cd $DIR
ls -l
exit 0
$

So does php have a way to do this that is as simple as it might be in
perl, for example?
--
Cal
Re: randomly sorting files in php [message #180579 is a reply to message #180578] Fri, 01 March 2013 04:45 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/28/2013 8:49 PM, Cal Dershowitz wrote:
> Hello ng,
>
> I've got a working localhost and a couple php scripts that run so far,
> so I wanted to see what types of things I can do and cannot do. This is
> by no means clear to me to me now.
>
> What I have is a collection of my own music files that I have put in the
> path of where localhost is looking for things; with my default install,
> that is /var/www.
>
> I wrote a bash script to export the files off my mp3 player, because
> neither my gf nor I who bought these things can figure how to make them
> play randomly. Yes we have achieved a certain age, where determination
> makes up for a lot.
>
> $ cat music1.sh
> #!/bin/bash
>
> set -e
> FROM='CCE0-705F'
> DIR='music1'
> mkdir -p $DIR
> cp $FROM/*.wma $DIR/
> cp $FROM/*.mp3 $DIR/
> cd $DIR
> ls -l
> exit 0
> $
>
> So does php have a way to do this that is as simple as it might be in
> perl, for example?

Sure, you *can* do it in PHP. But if you have a working bash script,
why reinvent the wheel? Especially since it sounds like you don't know
much about PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: randomly sorting files in php [message #180580 is a reply to message #180579] Fri, 01 March 2013 06:23 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 02/28/2013 08:45 PM, Jerry Stuckle wrote:
> On 2/28/2013 8:49 PM, Cal Dershowitz wrote:

>> So does php have a way to do this that is as simple as it might be in
>> perl, for example?
>
> Sure, you *can* do it in PHP. But if you have a working bash script,
> why reinvent the wheel? Especially since it sounds like you don't know
> much about PHP.
>

Well, if I can't invoke random behavior, I can't think that I have any
Thuring-compliant medium.

It's to be taken as a learning-example. I can accomplish this in every
syntax I know. I'd like to accomplish this in one I don't.
--
Cal
Re: randomly sorting files in php [message #180581 is a reply to message #180580] Fri, 01 March 2013 06:54 Go to previous messageGo to next message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma: 0
Junior Member
Cal Dershowitz wrote:

> On 02/28/2013 08:45 PM, Jerry Stuckle wrote:
>> On 2/28/2013 8:49 PM, Cal Dershowitz wrote:
>
>>> So does php have a way to do this that is as simple as it might be in
>>> perl, for example?
>>
>> Sure, you *can* do it in PHP. But if you have a working bash script,
>> why reinvent the wheel? Especially since it sounds like you don't know
>> much about PHP.
>>
>
> Well, if I can't invoke random behavior, I can't think that I have any
> Thuring-compliant medium.
>
> It's to be taken as a learning-example. I can accomplish this in every
> syntax I know. I'd like to accomplish this in one I don't.

Have a look at these functions for starters:

rand()
array_rand()
shuffle()

--
Cheers
David Robley

It is bad luck to be superstitious.
Re: randomly sorting files in php [message #180590 is a reply to message #180581] Mon, 04 March 2013 02:59 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 02/28/2013 10:54 PM, David Robley wrote:

> Have a look at these functions for starters:
>
> rand()
> array_rand()
> shuffle()
>

Alright, David, I'm pleased with how far I've gotten with this so far

$ pwd
/var/www
$ ls
CCE0-705F index.html read_dir1.php read_dir3.php read_dir5.php
date.php music1 read_dir1.php~ read_dir3.php~ read_dir5.php~
date.php~ music1.sh read_dir2.php read_dir4.php test.php
hello.php music1.sh~ read_dir2.php~ read_dir4.php~ Untitled Document
$ cat read_dir4.php
<?php

function getFilesFromDir($dir) {

$files = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(is_dir($dir.'/'.$file)) {
$dir2 = $dir.'/'.$file;
$files[] = getFilesFromDir($dir2);
}
else {
$files[] = $dir.'/'.$file;
}
}
}
closedir($handle);
}

return array_flat($files);
}

function array_flat($array) {

foreach($array as $a) {
if(is_array($a)) {
$tmp = array_merge($tmp, array_flat($a));
}
else {
$tmp[] = $a;
}
}

return $tmp;
}

// Usage
$dir = 'music1';
$foo = getFilesFromDir($dir);

print_r($foo);
?>
$

This is my fourth version of this script, obviously written primarily by
someone with more experience.

The output is tremendous, and the next step is to use a regex to knock
off leading numbers and underscores. I have a simple question.

Given that you have the data in an array that is instantiated like this,
how does one use best php form to use a regex on the whole thing?
--
Cal
Re: randomly sorting files in php [message #180593 is a reply to message #180578] Mon, 04 March 2013 10:45 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Mar 1, 1:49 am, Cal Dershowitz <c...@example.invalid> wrote:
> Hello ng,
>
> I've got a working localhost and a couple php scripts that run so far,
> so I wanted to see what types of things I can do and cannot do.  This is
> by no means clear to me to me now.
>
> What I have is a collection of my own music files that I have put in the
> path of where localhost is looking for things; with my default install,
> that is /var/www.
>
> I wrote a bash script to export the files off my mp3 player, because
> neither my gf nor I who bought these things can figure how to make them
> play randomly.  Yes we have achieved a certain age, where determination
> makes up for a lot.
>
> $ cat music1.sh
> #!/bin/bash
>
> set -e
> FROM='CCE0-705F'
> DIR='music1'
> mkdir -p $DIR
> cp  $FROM/*.wma $DIR/
> cp  $FROM/*.mp3 $DIR/
> cd $DIR
> ls -l
> exit 0
> $
>
> So does php have a way to do this that is as simple as it might be in
> perl, for example?
> --
> Cal

Do you know what order the mp3 player uses to decide the order of
play? If for instance it plays in alphabetical order of file name,
then the only way to get them played randomly is to rename them. On
the other hand it could be based on the order in which they are copied
to the device.
getting perl and php to talk to each other, was Re: randomly sorting files in php [message #180596 is a reply to message #180590] Tue, 05 March 2013 09:19 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
[x-posted to clp.misc]

On 03/03/2013 06:59 PM, Cal Dershowitz wrote:

> On 02/28/2013 10:54 PM, David Robley wrote:
>
>> Have a look at these functions for starters:
>>
>> rand()
>> array_rand()
>> shuffle()
>>
>
> Alright, David, I'm pleased with how far I've gotten with this so far
>
> $ pwd
> /var/www
> $ ls
> CCE0-705F index.html read_dir1.php read_dir3.php read_dir5.php
> date.php music1 read_dir1.php~ read_dir3.php~ read_dir5.php~
> date.php~ music1.sh read_dir2.php read_dir4.php test.php
> hello.php music1.sh~ read_dir2.php~ read_dir4.php~ Untitled Document
> $ cat read_dir4.php
> <?php
>
> function getFilesFromDir($dir) {
>
> $files = array();
> if ($handle = opendir($dir)) {
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..") {
> if(is_dir($dir.'/'.$file)) {
> $dir2 = $dir.'/'.$file;
> $files[] = getFilesFromDir($dir2);
> }
> else {
> $files[] = $dir.'/'.$file;
> }
> }
> }
> closedir($handle);
> }
>
> return array_flat($files);
> }
>
> function array_flat($array) {
>
> foreach($array as $a) {
> if(is_array($a)) {
> $tmp = array_merge($tmp, array_flat($a));
> }
> else {
> $tmp[] = $a;
> }
> }
>
> return $tmp;
> }
>
> // Usage
> $dir = 'music1';
> $foo = getFilesFromDir($dir);
>
> print_r($foo);
> ?>
> $
>
> This is my fourth version of this script, obviously written primarily by
> someone with more experience.
>
> The output is tremendous, and the next step is to use a regex to knock
> off leading numbers and underscores. I have a simple question.
>
> Given that you have the data in an array that is instantiated like this,
> how does one use best php form to use a regex on the whole thing?

This article has me convinced that I want perl and php able to deal with
each other:

http://www.linuxjournal.com/article/9282?page=0,1

The install didn't succumb to my first try, nor the second, which was this:

cpan[1]> install PHP::Interpreter
Going to read '/home/fred/.cpan/Metadata'
Database was generated on Mon, 28 Jan 2013 12:06:54 GMT
Fetching with LWP:
http://cpan.cs.utah.edu/authors/01mailrc.txt.gz
....

so far so good, and then this thing which I've seen in the literature:

using php_config 'php-config'
Can't exec "php-config": No such file or directory at Makefile.PL line 55.
Failed to find the 'php-config' executable. Make sure you have PHP and
PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
line 55.
....

bla bla bla do not pass Go. Right now I have a default installation.

Simple question: What types of things can I get configured with
php-config? envelope data available? ftp data?
--
Cal
Re: getting perl and php to talk to each other, was Re: randomly sorting files in php [message #180597 is a reply to message #180596] Tue, 05 March 2013 18:43 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 05.03.2013 10:19, schrieb Cal Dershowitz:
>
> This article has me convinced that I want perl and php able to deal with each other:
>
> http://www.linuxjournal.com/article/9282?page=0,1
>

Why not instantiate a Lua interpreter in perl? Or Ruby? And the picture on the
provided links show _who_ is doing that.

Now, seriously, this is of limited use.

/Str.
Re: getting perl and php to talk to each other, was Re: randomly sorting files in php [message #180598 is a reply to message #180597] Tue, 05 March 2013 19:20 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 05/03/13 18:43, M. Strobel wrote:
> Am 05.03.2013 10:19, schrieb Cal Dershowitz:
>>
>> This article has me convinced that I want perl and php able to deal with each other:
>>
>> http://www.linuxjournal.com/article/9282?page=0,1
>>
>
> Why not instantiate a Lua interpreter in perl? Or Ruby? And the picture on the
> provided links show _who_ is doing that.
>
> Now, seriously, this is of limited use.
>
> /Str.
>
I am sure there is a huge market for anything that can translate between
Gaelic and Linear B.

Someone told me so, when they were trying to raise the capital:-)

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: getting perl and php to talk to each other [message #180599 is a reply to message #180596] Tue, 05 March 2013 22:06 Go to previous messageGo to next message
Ben Morrow is currently offline  Ben Morrow
Messages: 5
Registered: March 2013
Karma: 0
Junior Member
Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
> [x-posted to clp.misc]
[...]
>
> This article has me convinced that I want perl and php able to deal with
> each other:
>
> http://www.linuxjournal.com/article/9282?page=0,1

Why on Earth would you want to do that? Seriously, I can't think of any
situation where mixing PHP and Perl is easier than just writing in Perl
in the first place.

Note that the Perl in that article (or at least, the first page, which
was all I read) is pretty bad:

- use of global filehandles, unnecessary since 2000,
- use of Thread.pm, deprecated since 2002,
- use of threads at all for such a trivial problem,
- using rindex and substr rather than pattern matching,
- using backticks instead of system(),
- using PHP to talk to a database, when Perl's DBI module is
considerably better than PHP's rather random database functions.

I don't know PHP well enough to comment on it, but I wouldn't be
surprised if the PHP code was just as bad (for instance, I understand
PHP has a saner database interface these days; I don't know if it
existed in 2007, though).

> so far so good, and then this thing which I've seen in the literature:
>
> using php_config 'php-config'
> Can't exec "php-config": No such file or directory at Makefile.PL line 55.
> Failed to find the 'php-config' executable. Make sure you have PHP and
> PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
> line 55.
> ...
>
> bla bla bla do not pass Go. Right now I have a default installation.
>
> Simple question: What types of things can I get configured with
> php-config? envelope data available? ftp data?

php-config is a program installed with php, which tells other programs
how php was installed. For instance, on my system

~% php-config --libs
-lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
~% php-config --includes
-I/usr/local/include/php -I/usr/local/include/php/main
-I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
-I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
~%

and so on. If you've installed php properly (including any required
development packages, if you're using a package system), you should have
a php-config executable somewhere. Make sure it's in your PATH before
running Makefile.PL.

Ben
Re: getting perl and php to talk to each other [message #180600 is a reply to message #180599] Tue, 05 March 2013 23:20 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
[X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

Ben Morrow wrote:

> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>> [x-posted to clp.misc]
> [...]
>>
>> This article has me convinced that I want perl and php able to deal with
>> each other:
>>
>> http://www.linuxjournal.com/article/9282?page=0,1
>
> Why on Earth would you want to do that? Seriously, I can't think of any
> situation where mixing PHP and Perl is easier than just writing in Perl
> in the first place.

Other people would say the same about writing PHP instead of a mix.

However, there can be value in two programming languages in the same
program. Just consider what kinds of data you can pass via the command
line and what kinds you cannot pass that way (yes, there are text files,
named pipes, and other equally ugly workarounds).

> Note that the Perl in that article (or at least, the first page, which
> was all I read) is pretty bad:
>
> […]
> - using PHP to talk to a database, when Perl's DBI module is
> considerably better than PHP's rather random database functions.
>
> I don't know PHP well enough to comment on it,

Yet you did, which shows that you have never used PHP Data Objects (PDO).
“*Random* database functions”? IBTD.

> but I wouldn't be surprised if the PHP code was just as bad (for instance,
> I understand PHP has a saner database interface these days; I don't know
> if it existed in 2007, though).

It did; for example, “PDO [shipped] with PHP 5.1”, “[r]eleased: 24 Nov
2005”, which is not that hard to find out:

<http://www.php.net/manual/en/intro.pdo.php>
<http://www.php.net/releases/>


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
Re: getting perl and php to talk to each other [message #180601 is a reply to message #180600] Tue, 05 March 2013 23:59 Go to previous messageGo to next message
Ben Morrow is currently offline  Ben Morrow
Messages: 5
Registered: March 2013
Karma: 0
Junior Member
Quoth Thomas 'PointedEars' Lahn <php(at)PointedEars(dot)de>:
> [X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]

OK. As such I won't see any replies.

> Ben Morrow wrote:
>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>> [x-posted to clp.misc]
>> [...]
>>>
>>> This article has me convinced that I want perl and php able to deal with
>>> each other:
>>>
>>> http://www.linuxjournal.com/article/9282?page=0,1
>>
>> Why on Earth would you want to do that? Seriously, I can't think of any
>> situation where mixing PHP and Perl is easier than just writing in Perl
>> in the first place.
>
> Other people would say the same about writing PHP instead of a mix.

Yes, of course.

> However, there can be value in two programming languages in the same
> program. Just consider what kinds of data you can pass via the command
> line and what kinds you cannot pass that way (yes, there are text files,
> named pipes, and other equally ugly workarounds).

The methods used by PHP::Interpreter are not really any less ugly. Until
you get to the point of being able to run the two languages on the same
VM with properly interworking data structures (such as Parrot is trying
to achieve, for instance) I don't see much point stuffing the two
languages into the same process and then just passing strings to eval
back and forth.

>> Note that the Perl in that article (or at least, the first page, which
>> was all I read) is pretty bad:
>>
>> […]
>> - using PHP to talk to a database, when Perl's DBI module is
>> considerably better than PHP's rather random database functions.
>>
>> I don't know PHP well enough to comment on it,
>
> Yet you did, which shows that you have never used PHP Data Objects (PDO).
> “*Random* database functions”? IBTD.

I have not. The database functions used in the article referenced were
mssql_connect and so on, which last time I used PHP (a long time ago)
was all there was. I don't think you can deny that *those* functions
(and the equivalent set for other databases) are a nasty mess. I tried
to make it clear that I understand the state of the PHP art has improved
since then.

My major point was that I don't see any good reason to call into PHP
just to connect to a database, when Perl already has perfectly good
database code. Had the example been written the other way around the
equivalent point could of course have been made about calling into Perl.

>> but I wouldn't be surprised if the PHP code was just as bad (for instance,
>> I understand PHP has a saner database interface these days; I don't know
>> if it existed in 2007, though).
>
> It did; for example, “PDO [shipped] with PHP 5.1”, “[r]eleased: 24 Nov
> 2005”, which is not that hard to find out:

Not that hard had I been interested, which I'm not, and had I known
'PDO' was the term to look for, which I didn't. (I was actually thinking
of the PEAR DB module, which I've observed is a thing that exists.
Again, I've no idea if this is the currently-recommended database
interface, or how it compares with the Perl DBI.)

Ben
Re: getting perl and php to talk to each other [message #180602 is a reply to message #180601] Wed, 06 March 2013 01:01 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
It's bad enough having to wrote what amounts to JavaScript, SQL and PHP
in the same program without adding PERL..

I dunno why people always want to make things needlessly complicated.
Obviously they are being paid to much and are not given enough work to do/.

My Linus system is already full of crap I really would prefer not to
have, PERL, python.. all modern equivalents of MS BASIC.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: getting perl and php to talk to each other [message #180603 is a reply to message #180601] Wed, 06 March 2013 01:08 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/5/2013 6:59 PM, Ben Morrow wrote:
>
> Quoth Thomas 'PointedEars' Lahn <php(at)PointedEars(dot)de>:
>> [X-Post & F'up2 comp.lang.php; please do not X-Post without F'up2]
>
> OK. As such I won't see any replies.
>

Don't worry about Pointed Head. He's a well known troll in several
newsgroups.

<snip>

>>> Why on Earth would you want to do that? Seriously, I can't think of any
>>> situation where mixing PHP and Perl is easier than just writing in Perl
>>> in the first place.
>>
>> Other people would say the same about writing PHP instead of a mix.
>
> Yes, of course.
>

A long shot - maybe you have a package in one language you need to feed
input to. But that input must first be processed by a package in the
other language. Rather than rewrite everything, merge them together.

Or, perhaps you need to build the data preprocessor, and aren't familiar
with the language the package is written in.

I agree it would be quite rare, but it's about the only reason I could
think of people would need both languages. I'm sure there are more, though.

>> However, there can be value in two programming languages in the same
>> program. Just consider what kinds of data you can pass via the command
>> line and what kinds you cannot pass that way (yes, there are text files,
>> named pipes, and other equally ugly workarounds).
>
> The methods used by PHP::Interpreter are not really any less ugly. Until
> you get to the point of being able to run the two languages on the same
> VM with properly interworking data structures (such as Parrot is trying
> to achieve, for instance) I don't see much point stuffing the two
> languages into the same process and then just passing strings to eval
> back and forth.
>

I doubt that they'll ever have internetworking data structures, though.
Just not a need for it.

>>> Note that the Perl in that article (or at least, the first page, which
>>> was all I read) is pretty bad:
>>>
>>> […]
>>> - using PHP to talk to a database, when Perl's DBI module is
>>> considerably better than PHP's rather random database functions.
>>>
>>> I don't know PHP well enough to comment on it,
>>
>> Yet you did, which shows that you have never used PHP Data Objects (PDO).
>> “*Random* database functions”? IBTD.
>
> I have not. The database functions used in the article referenced were
> mssql_connect and so on, which last time I used PHP (a long time ago)
> was all there was. I don't think you can deny that *those* functions
> (and the equivalent set for other databases) are a nasty mess. I tried
> to make it clear that I understand the state of the PHP art has improved
> since then.
>
> My major point was that I don't see any good reason to call into PHP
> just to connect to a database, when Perl already has perfectly good
> database code. Had the example been written the other way around the
> equivalent point could of course have been made about calling into Perl.
>

I agree with both of your points. Both languages have reasonable means
of accessing data. I don't think there are any databases one language
can access but not the other.

However, I wouldn't call those functions a "nasty mess". But then I was
writing C code > 25 years ago, and these are just wrappers around C
functions. And while there are other ways such as PDO, they also
typically add an extra layer of overhead. In a busy system, this may or
may not be important. However, if the system is that busy, I wouldn't
be switching back and forth between languages, either.


>>> but I wouldn't be surprised if the PHP code was just as bad (for instance,
>>> I understand PHP has a saner database interface these days; I don't know
>>> if it existed in 2007, though).
>>
>> It did; for example, “PDO [shipped] with PHP 5.1”, “[r]eleased: 24 Nov
>> 2005”, which is not that hard to find out:
>
> Not that hard had I been interested, which I'm not, and had I known
> 'PDO' was the term to look for, which I didn't. (I was actually thinking
> of the PEAR DB module, which I've observed is a thing that exists.
> Again, I've no idea if this is the currently-recommended database
> interface, or how it compares with the Perl DBI.)
>
> Ben
>

I wouldn't have bothered looking up when a Perl module was shipped, either.

BTW - comp.lang.perl.misc added back since this is about both languages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180604 is a reply to message #180601] Wed, 06 March 2013 01:08 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Ben Morrow wrote:

> Quoth Thomas 'PointedEars' Lahn <php(at)PointedEars(dot)de>:
>> Ben Morrow wrote:
>>> Note that the Perl in that article (or at least, the first page, which
>>> was all I read) is pretty bad:
>>>
>>> […]
>>> - using PHP to talk to a database, when Perl's DBI module is
>>> considerably better than PHP's rather random database functions.
>>>
>>> I don't know PHP well enough to comment on it,
>>
>> Yet you did, which shows that you have never used PHP Data Objects (PDO).
>> “*Random* database functions”? IBTD.
>
> I have not. The database functions used in the article referenced were
> mssql_connect and so on, which last time I used PHP (a long time ago)
> was all there was. I don't think you can deny that *those* functions
> (and the equivalent set for other databases) are a nasty mess.

Most certainly I deny that. I agree that several of those functions are
unsafe, and it is unfortunate that the order of arguments for MS SQL is
different than, for example, MySQL. But IMHO that is still a long way from
“a nasty mess”. They have been used and have worked for the better part of
a decade. After all, they have helped to build the Web that we have today,
so they cannot be all bad, can they?

AFAIK the first step towards a better interface (with support for Prepared
Statements) was mysqli by MySQL AB, now Oracle, with PHP 5.0 or later. Then
came PDO and others.

> I tried to make it clear that I understand the state of the PHP art has
> improved since then.

The state of the PHP art as the article suggests was even better back then.
You should not assume that the quality of PHP code as it can be found in
such articles, in blogs, and Web forums reflects the quality of the
programming language at the time. In fact, you would do well to assume that
it reflects the exact opposite. The same is true for other (overly)
beginner-friendly languages, for example ECMAScript implementations like
JavaScript. (And if you know that ECMAScript and its implementations as
well as PHP range among my favorite languages despite their flaws, you also
know that I do not make such statements lightly.)

> My major point was that I don't see any good reason to call into PHP
> just to connect to a database, when Perl already has perfectly good
> database code. Had the example been written the other way around the
> equivalent point could of course have been made about calling into Perl.
>
>>> but I wouldn't be surprised if the PHP code was just as bad (for
>>> instance, I understand PHP has a saner database interface these days; I
>>> don't know if it existed in 2007, though).
>>
>> It did; for example, “PDO [shipped] with PHP 5.1”, “[r]eleased: 24 Nov
>> 2005”, which is not that hard to find out:
>
> Not that hard had I been interested, which I'm not, and had I known
> 'PDO' was the term to look for, which I didn't.

Please don't play stupid with me. That section is part of a chapter of the
PHP manual about several database interfaces.

> (I was actually thinking of the PEAR DB module, which I've observed is a
> thing that exists.

Many things exist on PEAR, written by third parties, some with stupid
interfaces; the same was as many things exist on CPAN, some with stupid
interfaces.

<OT>

For example, I remember Number::Format from CPAN to be particularly stupid
with regard to locales:

my ( $thousands_sep, $mon_thousands_sep, $grouping, $decimal_point ) =
@{ localeconv() }{ 'thousands_sep', 'mon_thousands_sep', 'grouping',
'decimal_point' };

# Apply defaults if values are missing
$thousands_sep = $mon_thousands_sep unless $thousands_sep;
$thousands_sep = ' ' unless $thousands_sep;

# grouping and mon_grouping are packed lists
# of small integers (characters) telling the
# grouping (thousand_seps and mon_thousand_seps
# being the group dividers) of numbers and
# monetary quantities. The integers' meanings:
# 255 means no more grouping, 0 means repeat
# the previous grouping, 1-254 means use that
# as the current grouping. Grouping goes from
# right to left (low to high digits). In the
# below we cheat slightly by never using anything
# else than the first grouping (whatever that is).
my @grouping;
if ($grouping)
{
@grouping = unpack( "C*", $grouping );
}
else
{
@grouping = (3);
}

## FIXME: Why don't the defaults work already?
my $formatter = new Number::Format(
-decimal_point => $decimal_point,
-thousands_sep => $thousands_sep,
-kibi_suffix => ' KiB',
-mebi_suffix => ' MiB',
-gibi_suffix => ' GiB',

# -grouping => $grouping[0]
);

echo $formatter->format(421337);

----
Does that not qualify as a “god-awful mess” for you for something so basic
such as formatting numbers? [It is not really better in PHP with
number_format(), though. Apparently, despite its obvious importance – what
have *computers* originally been built for? –, easy and proper number
formatting, and string formatting in general, apparently is not on the list
of priorities in many programming language designs. As if many language
designers subscribed to the paradigm ”Who cares? Let the developer reinvent
the wheel over and over again” :-/]

</OT>

> Again, I've no idea if this is the currently-recommended database
> interface, or how it compares with the Perl DBI.)

I can recommend it from professional experience, because it is a very clean
and efficient, object-oriented, easily customizable, and rather compatible
interface. Zend Framework uses it by default, for example. Which allows
you in many cases just to switch the database adapter if you switch the
DBMS. (In case you do not know, the people who wrote/write the PHP VM are
at Zend.)

So I can only strongly suggest again that you RTFM and STFW before you make
any statement about languages that you say (or think) you do not know well
enough to make statements about, unless you want to make a fool out of
yourself.


HTH

PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Re: getting perl and php to talk to each other [message #180618 is a reply to message #180603] Thu, 07 March 2013 06:37 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/05/2013 05:08 PM, Jerry Stuckle wrote:
> On 3/5/2013 6:59 PM, Ben Morrow wrote:

>>>> Why on Earth would you want to do that? Seriously, I can't think of any
>>>> situation where mixing PHP and Perl is easier than just writing in Perl
>>>> in the first place.
>>>
>>> Other people would say the same about writing PHP instead of a mix.
>>
>> Yes, of course.
>>
>
> A long shot - maybe you have a package in one language you need to feed
> input to. But that input must first be processed by a package in the
> other language. Rather than rewrite everything, merge them together.

What I wanted to do that this article had mentioned was to be able to
call perl reliably either from php or from a bash script that
comprehends it all.
>
> Or, perhaps you need to build the data preprocessor, and aren't familiar
> with the language the package is written in.

I've chosen this rather arbitrary task just to see what I can do with
this syntax which is new to me, php, as opposed to what a person can do
with, perl, which I have previously used to give me a webpage.
>
> I agree it would be quite rare, but it's about the only reason I could
> think of people would need both languages. I'm sure there are more,
> though.

Can I use perl regex's or do I have to learn a whole 'nother idea of
what that is?
>
>>> However, there can be value in two programming languages in the same
>>> program. Just consider what kinds of data you can pass via the command
>>> line and what kinds you cannot pass that way (yes, there are text files,
>>> named pipes, and other equally ugly workarounds).
>>
>> The methods used by PHP::Interpreter are not really any less ugly. Until
>> you get to the point of being able to run the two languages on the same
>> VM with properly interworking data structures (such as Parrot is trying
>> to achieve, for instance) I don't see much point stuffing the two
>> languages into the same process and then just passing strings to eval
>> back and forth.
>>
>
> I doubt that they'll ever have internetworking data structures, though.
> Just not a need for it.

No, nothing like that complex.

[snip]

[OT]
> I wouldn't have bothered looking up when a Perl module was shipped, either.
>
> BTW - comp.lang.perl.misc added back since this is about both languages.
>

I'm not thrilled with being OT again, but I just can't get
PHP::Interpreter to install and don't know exactly why. I don't like to
be OT, but something that seems to work for others isn't for me now, and
it's not at the level of scripting languages.

I can ask very-flawed specific questions but need to wonder aloud why
php-config doesn't work, why files that are supposed to be there aren't,
and how I troubleshoot the basic function of it before I actually get
this topic off the ground.

What exactly do I have to do at this point to get a php-config that
works as far as PHP::Interpreter is concerned?

I've tried ten things that don't work.
--
Cal
Re: getting perl and php to talk to each other [message #180619 is a reply to message #180599] Thu, 07 March 2013 06:53 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/05/2013 02:06 PM, Ben Morrow wrote:
>
> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>> [x-posted to clp.misc]
> [...]
>>
>> This article has me convinced that I want perl and php able to deal with
>> each other:
>>
>> http://www.linuxjournal.com/article/9282?page=0,1
>
> Why on Earth would you want to do that? Seriously, I can't think of any
> situation where mixing PHP and Perl is easier than just writing in Perl
> in the first place.
>
> Note that the Perl in that article (or at least, the first page, which
> was all I read) is pretty bad:
>
> - use of global filehandles, unnecessary since 2000,
> - use of Thread.pm, deprecated since 2002,
> - use of threads at all for such a trivial problem,
> - using rindex and substr rather than pattern matching,
> - using backticks instead of system(),
> - using PHP to talk to a database, when Perl's DBI module is
> considerably better than PHP's rather random database functions.
>
> I don't know PHP well enough to comment on it, but I wouldn't be
> surprised if the PHP code was just as bad (for instance, I understand
> PHP has a saner database interface these days; I don't know if it
> existed in 2007, though).
>
>> so far so good, and then this thing which I've seen in the literature:
>>
>> using php_config 'php-config'
>> Can't exec "php-config": No such file or directory at Makefile.PL line 55.
>> Failed to find the 'php-config' executable. Make sure you have PHP and
>> PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
>> line 55.
>> ...
>>
>> bla bla bla do not pass Go. Right now I have a default installation.
>>
>> Simple question: What types of things can I get configured with
>> php-config? envelope data available? ftp data?
>
> php-config is a program installed with php, which tells other programs
> how php was installed. For instance, on my system
>
> ~% php-config --libs
> -lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
> ~% php-config --includes
> -I/usr/local/include/php -I/usr/local/include/php/main
> -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
> -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
> ~%
>
> and so on. If you've installed php properly (including any required
> development packages, if you're using a package system), you should have
> a php-config executable somewhere. Make sure it's in your PATH before
> running Makefile.PL.

Struggling.

$ php-config --libs
No command 'php-config' found, did you mean:
Command 'pdp-config' from package 'pd-pdp' (universe)
Command 'php-config5' from package 'php5-dev' (main)
php-config: command not found
$
--
Cal
Re: getting perl and php to talk to each other [message #180620 is a reply to message #180618] Thu, 07 March 2013 06:57 Go to previous messageGo to next message
Ben Morrow is currently offline  Ben Morrow
Messages: 5
Registered: March 2013
Karma: 0
Junior Member
Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>
> I've chosen this rather arbitrary task just to see what I can do with
> this syntax which is new to me, php, as opposed to what a person can do
> with, perl, which I have previously used to give me a webpage.

Cal, please, try to learn one language properly before wildly
introducing more languages to the equation. It *really* isn't going to
help.

> What exactly do I have to do at this point to get a php-config that
> works as far as PHP::Interpreter is concerned?

I have already answered that question.

Ben
Re: getting perl and php to talk to each other [message #180621 is a reply to message #180619] Thu, 07 March 2013 08:46 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 07.03.2013 07:53, schrieb Cal Dershowitz:
> On 03/05/2013 02:06 PM, Ben Morrow wrote:

>> and so on. If you've installed php properly (including any required
>> development packages, if you're using a package system), you should have
>> a php-config executable somewhere. Make sure it's in your PATH before
>> running Makefile.PL.
>
> Struggling.
>
> $ php-config --libs
> No command 'php-config' found, did you mean:
> Command 'pdp-config' from package 'pd-pdp' (universe)
> Command 'php-config5' from package 'php5-dev' (main)
> php-config: command not found
> $

strobel@suse122-intel:~> php-config --libs
-lcrypt -lresolv -lpcre -lcrypt -lcrypt -lrt -lm -ldl -lnsl -lrt -lcrypt -lcrypt
-lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt
strobel@suse122-intel:~>

So the "...If you've installed php properly..." still holds.

/Str.
Re: getting perl and php to talk to each other [message #180622 is a reply to message #180620] Thu, 07 March 2013 08:52 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/06/2013 10:57 PM, Ben Morrow wrote:
>
> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>
>> I've chosen this rather arbitrary task just to see what I can do with
>> this syntax which is new to me, php, as opposed to what a person can do
>> with, perl, which I have previously used to give me a webpage.
>
> Cal, please, try to learn one language properly before wildly
> introducing more languages to the equation. It *really* isn't going to
> help.

Help what? Are you certain that it's completely impossible that a file
could go missing from me that I would need to do this, and that there
would be every reason in this fascist world world to keep me from
getting a decent web capability?

I don't seem to be loading up facebook.ben.pl very often.
>
>> What exactly do I have to do at this point to get a php-config that
>> works as far as PHP::Interpreter is concerned?
>
> I have already answered that question.
>
> Ben
>

Can I bother you to repeat it?
--
Cal
Re: getting perl and php to talk to each other [message #180623 is a reply to message #180621] Thu, 07 March 2013 11:13 Go to previous messageGo to next message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma: 0
Junior Member
M. Strobel wrote:

> Am 07.03.2013 07:53, schrieb Cal Dershowitz:
>> On 03/05/2013 02:06 PM, Ben Morrow wrote:
>
>>> and so on. If you've installed php properly (including any required
>>> development packages, if you're using a package system), you should have
>>> a php-config executable somewhere. Make sure it's in your PATH before
>>> running Makefile.PL.
>>
>> Struggling.
>>
>> $ php-config --libs
>> No command 'php-config' found, did you mean:
>> Command 'pdp-config' from package 'pd-pdp' (universe)
>> Command 'php-config5' from package 'php5-dev' (main)
>> php-config: command not found
>> $
>
> strobel@suse122-intel:~> php-config --libs
> -lcrypt -lresolv -lpcre -lcrypt -lcrypt -lrt -lm -ldl -lnsl -lrt -lcrypt
> -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt
> strobel@suse122-intel:~>
>
> So the "...If you've installed php properly..." still holds.
>
> /Str.

Ooh, I can show more than that :-)

bash-4.1$ php-config --libs
-lcrypt -lz -lexslt -lresolv -lcrypt -lrt -lmysqlclient -lfreetype -lX11 -
lXpm -lpng -lz -ljpeg -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -lssl -lcrypto
-ldl -lxml2 -lz -lm -lmysqlclient -lm -lrt -ldl -lmysqlclient -lm -lrt -ldl
-lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxslt -
lxml2 -lz -lm -lcrypt



--
Cheers
David Robley

Who is General Failure and why is he reading my disk?
Re: getting perl and php to talk to each other [message #180624 is a reply to message #180619] Thu, 07 March 2013 11:28 Go to previous messageGo to next message
SwissCheese is currently offline  SwissCheese
Messages: 17
Registered: December 2012
Karma: 0
Junior Member
On 03/07/2013 01:53 AM, Cal Dershowitz wrote:
> On 03/05/2013 02:06 PM, Ben Morrow wrote:
>>
>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>> [x-posted to clp.misc]
>> [...]
>>>
>>> This article has me convinced that I want perl and php able to deal with
>>> each other:
>>>
>>> http://www.linuxjournal.com/article/9282?page=0,1
>>
>> Why on Earth would you want to do that? Seriously, I can't think of any
>> situation where mixing PHP and Perl is easier than just writing in Perl
>> in the first place.
>>
>> Note that the Perl in that article (or at least, the first page, which
>> was all I read) is pretty bad:
>>
>> - use of global filehandles, unnecessary since 2000,
>> - use of Thread.pm, deprecated since 2002,
>> - use of threads at all for such a trivial problem,
>> - using rindex and substr rather than pattern matching,
>> - using backticks instead of system(),
>> - using PHP to talk to a database, when Perl's DBI module is
>> considerably better than PHP's rather random database functions.
>>
>> I don't know PHP well enough to comment on it, but I wouldn't be
>> surprised if the PHP code was just as bad (for instance, I understand
>> PHP has a saner database interface these days; I don't know if it
>> existed in 2007, though).
>>
>>> so far so good, and then this thing which I've seen in the literature:
>>>
>>> using php_config 'php-config'
>>> Can't exec "php-config": No such file or directory at Makefile.PL
>>> line 55.
>>> Failed to find the 'php-config' executable. Make sure you have PHP and
>>> PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
>>> line 55.
>>> ...
>>>
>>> bla bla bla do not pass Go. Right now I have a default installation.
>>>
>>> Simple question: What types of things can I get configured with
>>> php-config? envelope data available? ftp data?
>>
>> php-config is a program installed with php, which tells other programs
>> how php was installed. For instance, on my system
>>
>> ~% php-config --libs
>> -lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
>> ~% php-config --includes
>> -I/usr/local/include/php -I/usr/local/include/php/main
>> -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
>> -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
>> ~%
>>
>> and so on. If you've installed php properly (including any required
>> development packages, if you're using a package system), you should have
>> a php-config executable somewhere. Make sure it's in your PATH before
>> running Makefile.PL.
>
> Struggling.
>
> $ php-config --libs
> No command 'php-config' found, did you mean:
> Command 'pdp-config' from package 'pd-pdp' (universe)
> Command 'php-config5' from package 'php5-dev' (main)
> php-config: command not found
> $

Try php-config5 as php-config is a link to php-config5. Here they
both reside in /usr/bin. If you are missing php-config link (it appears
so) then create it.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: getting perl and php to talk to each other [message #180625 is a reply to message #180618] Thu, 07 March 2013 13:14 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/7/2013 1:37 AM, Cal Dershowitz wrote:
> On 03/05/2013 05:08 PM, Jerry Stuckle wrote:
>> On 3/5/2013 6:59 PM, Ben Morrow wrote:
>
<snip>

> What I wanted to do that this article had mentioned was to be able to
> call perl reliably either from php or from a bash script that
> comprehends it all.

To what purpose?

<snip>

> I've chosen this rather arbitrary task just to see what I can do with
> this syntax which is new to me, php, as opposed to what a person can do
> with, perl, which I have previously used to give me a webpage.

To what purpose?

>>
>> I agree it would be quite rare, but it's about the only reason I could
>> think of people would need both languages. I'm sure there are more,
>> though.
>
> Can I use perl regex's or do I have to learn a whole 'nother idea of
> what that is?

If you're writing in PHP, you learn PHP's way of doing things. It also
has regex's (which are pretty close to Perl's).

<snip>

> I'm not thrilled with being OT again, but I just can't get
> PHP::Interpreter to install and don't know exactly why. I don't like to
> be OT, but something that seems to work for others isn't for me now, and
> it's not at the level of scripting languages.
>

Most people don't try to mix languages like you are. It overly
complicates things.

> I can ask very-flawed specific questions but need to wonder aloud why
> php-config doesn't work, why files that are supposed to be there aren't,
> and how I troubleshoot the basic function of it before I actually get
> this topic off the ground.
>
> What exactly do I have to do at this point to get a php-config that
> works as far as PHP::Interpreter is concerned?
>
> I've tried ten things that don't work.

So, how did you install PHP?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180626 is a reply to message #180622] Thu, 07 March 2013 13:17 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/7/2013 3:52 AM, Cal Dershowitz wrote:
> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>>
>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>
>>> I've chosen this rather arbitrary task just to see what I can do with
>>> this syntax which is new to me, php, as opposed to what a person can do
>>> with, perl, which I have previously used to give me a webpage.
>>
>> Cal, please, try to learn one language properly before wildly
>> introducing more languages to the equation. It *really* isn't going to
>> help.
>
> Help what? Are you certain that it's completely impossible that a file
> could go missing from me that I would need to do this, and that there
> would be every reason in this fascist world world to keep me from
> getting a decent web capability?
>

There are hundreds of millions of web sites which have "decent web
capabilities" but don't try to mix languages. I agree with Ben - learn
one language first.

And if you want help, I *highly* suggest you change your attitude.
Calling people facists does not endear ANYONE.

> I don't seem to be loading up facebook.ben.pl very often.
>>
>>> What exactly do I have to do at this point to get a php-config that
>>> works as far as PHP::Interpreter is concerned?
>>
>> I have already answered that question.
>>
>> Ben
>>
>
> Can I bother you to repeat it?

Can you bother to go back and read the earlier messages in this thread?

I've tried to help, but you are *quickly* wearing my patience with your
attitude.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180630 is a reply to message #180623] Thu, 07 March 2013 13:32 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 07 Mar 2013 21:43:50 +1030, David Robley wrote:
> Ooh, I can show more than that :-)
>
> bash-4.1$ php-config --libs
> -lcrypt -lz -lexslt -lresolv -lcrypt -lrt -lmysqlclient -lfreetype -lX11 -
> lXpm -lpng -lz -ljpeg -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -lssl -lcrypto
> -ldl -lxml2 -lz -lm -lmysqlclient -lm -lrt -ldl -lmysqlclient -lm -lrt -ldl
> -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxslt -
> lxml2 -lz -lm -lcrypt

"You said lxml2 seven times."
*hock-spit* "I like lxml2."

--
I got told by a friend's ex-girlfriend that she could tell I was
a Linux geek from the way I *walked*.
-- Skud
Re: getting perl and php to talk to each other [message #180631 is a reply to message #180622] Thu, 07 March 2013 14:25 Go to previous messageGo to next message
Ben Morrow is currently offline  Ben Morrow
Messages: 5
Registered: March 2013
Karma: 0
Junior Member
Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
> On 03/06/2013 10:57 PM, Ben Morrow wrote:
>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>
>>> I've chosen this rather arbitrary task just to see what I can do with
>>> this syntax which is new to me, php, as opposed to what a person can do
>>> with, perl, which I have previously used to give me a webpage.
>>
>> Cal, please, try to learn one language properly before wildly
>> introducing more languages to the equation. It *really* isn't going to
>> help.
>
> Help what? Are you certain that it's completely impossible that a file
> could go missing from me that I would need to do this, and that there
> would be every reason in this fascist world world to keep me from
> getting a decent web capability?

I am quite certain that whatever it is you are trying to accomplish, you
can do it more easily in either Perl or PHP alone than in both combined.

You seem to keep losing files. You should consider taking backups, or
using a version control system.

> I don't seem to be loading up facebook.ben.pl very often.

That makes no sense. If you want help, you should start by making at
least a token effort to make sense.

Ben
Re: getting perl and php to talk to each other [message #180632 is a reply to message #180624] Thu, 07 March 2013 14:33 Go to previous messageGo to next message
Ben Morrow is currently offline  Ben Morrow
Messages: 5
Registered: March 2013
Karma: 0
Junior Member
Quoth swisscheese(at)cfl(dot)rr(dot)com:
> On 03/07/2013 01:53 AM, Cal Dershowitz wrote:
>>
>> Struggling.
>>
>> $ php-config --libs
>> No command 'php-config' found, did you mean:
>> Command 'pdp-config' from package 'pd-pdp' (universe)
>> Command 'php-config5' from package 'php5-dev' (main)
>> php-config: command not found
>> $
>
> Try php-config5 as php-config is a link to php-config5. Here they
> both reside in /usr/bin. If you are missing php-config link (it appears
> so) then create it.

Installing the php-dev package should have created this link:
http://xrl.us/bomxwq .

Ben
Re: getting perl and php to talk to each other [message #180640 is a reply to message #180619] Thu, 07 March 2013 19:09 Go to previous messageGo to next message
alexd[1] is currently offline  alexd[1]
Messages: 1
Registered: March 2013
Karma: 0
Junior Member
Cal Dershowitz (for it is he) wrote:

> Struggling.
>
> $ php-config --libs
> No command 'php-config' found, did you mean:
> Command 'pdp-config' from package 'pd-pdp' (universe)
> Command 'php-config5' from package 'php5-dev' (main)
> php-config: command not found

I should think that anybody with a passing familiarity with package
management would be able to work out what this output is telling them.

--
<http://ale.cx/> (AIM:troffasky) (UnSoEsNpEaTm(at)ale(dot)cx)
19:08:28 up 80 days, 21:40, 8 users, load average: 0.91, 1.21, 1.25
Qua illic est reprehendit, illic est a vindicatum
Re: getting perl and php to talk to each other [message #180642 is a reply to message #180640] Thu, 07 March 2013 20:09 Go to previous messageGo to next message
Henry Law is currently offline  Henry Law
Messages: 1
Registered: March 2013
Karma: 0
Junior Member
On 07/03/13 19:09, alexd wrote:

> I should think that anybody with a passing familiarity with package
> management would be able to work out what this output is telling them.
>

ay, there’s the rub!

--

Henry Law Manchester, England
Re: getting perl and php to talk to each other [message #180643 is a reply to message #180640] Thu, 07 March 2013 20:43 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 07/03/13 19:09, alexd wrote:
> Cal Dershowitz (for it is he) wrote:
>
>> Struggling.
>>
>> $ php-config --libs
>> No command 'php-config' found, did you mean:
>> Command 'pdp-config' from package 'pd-pdp' (universe)
>> Command 'php-config5' from package 'php5-dev' (main)
>> php-config: command not found
>
> I should think that anybody with a passing familiarity with package
> management would be able to work out what this output is telling them.
>
a passing familiarity with package management is not a requirement for
running PHP or posting in this NG.

NOr is installation of php development files and utilities a requirement
fora basic LAMP setup.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: getting perl and php to talk to each other [message #180644 is a reply to message #180643] Thu, 07 March 2013 21:47 Go to previous messageGo to next message
Alastair Black is currently offline  Alastair Black
Messages: 3
Registered: March 2013
Karma: 0
Junior Member
On 03/07/2013 01:43 PM, The Natural Philosopher wrote:
> On 07/03/13 19:09, alexd wrote:
>> Cal Dershowitz (for it is he) wrote:
>>
>>> Struggling.
>>>
>>> $ php-config --libs
>>> No command 'php-config' found, did you mean:
>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>> Command 'php-config5' from package 'php5-dev' (main)
>>> php-config: command not found
>>
>> I should think that anybody with a passing familiarity with package
>> management would be able to work out what this output is telling them.
>>
> a passing familiarity with package management is not a requirement for
> running PHP or posting in this NG.
>
> NOr is installation of php development files and utilities a requirement
> fora basic LAMP setup.
>
>

If you say to the car dealer "I would like to buy
a cerise van" and the car dealer says "We don't
have cerise, how about red?" it makes no sense to
go to the coffee shop down the street and ask the
folks there "Why doesn't that car dealer have
cerise cars?"

Alastair
Re: getting perl and php to talk to each other [message #180646 is a reply to message #180644] Thu, 07 March 2013 22:11 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 07.03.2013 22:47, schrieb Alastair Black:
> On 03/07/2013 01:43 PM, The Natural Philosopher wrote:
>> On 07/03/13 19:09, alexd wrote:
>>> Cal Dershowitz (for it is he) wrote:
>>>
>>>> Struggling.
>>>>
>>>> $ php-config --libs
>>>> No command 'php-config' found, did you mean:
>>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>>> Command 'php-config5' from package 'php5-dev' (main)
>>>> php-config: command not found
>>>
>>> I should think that anybody with a passing familiarity with package
>>> management would be able to work out what this output is telling them.
>>>
>> a passing familiarity with package management is not a requirement for
>> running PHP or posting in this NG.
>>
>> NOr is installation of php development files and utilities a requirement
>> fora basic LAMP setup.
>>
>>
>
> If you say to the car dealer "I would like to buy
> a cerise van" and the car dealer says "We don't
> have cerise, how about red?" it makes no sense to
> go to the coffee shop down the street and ask the
> folks there "Why doesn't that car dealer have
> cerise cars?"

Your are trying to explain with an analogy, requiring abstraction, a problem you
could understand with simple logic.

/Str.
Re: getting perl and php to talk to each other [message #180647 is a reply to message #180646] Thu, 07 March 2013 22:50 Go to previous messageGo to next message
Alastair Black is currently offline  Alastair Black
Messages: 3
Registered: March 2013
Karma: 0
Junior Member
On 03/07/2013 03:11 PM, M. Strobel wrote:
> Am 07.03.2013 22:47, schrieb Alastair Black:
>> On 03/07/2013 01:43 PM, The Natural Philosopher wrote:
>>> On 07/03/13 19:09, alexd wrote:
>>>> Cal Dershowitz (for it is he) wrote:
>>>>
>>>> > Struggling.
>>>> >
>>>> > $ php-config --libs
>>>> > No command 'php-config' found, did you mean:
>>>> > Command 'pdp-config' from package 'pd-pdp' (universe)
>>>> > Command 'php-config5' from package 'php5-dev' (main)
>>>> > php-config: command not found
>>>>
>>>> I should think that anybody with a passing familiarity with package
>>>> management would be able to work out what this output is telling them.
>>>>
>>> a passing familiarity with package management is not a requirement for
>>> running PHP or posting in this NG.
>>>
>>> NOr is installation of php development files and utilities a requirement
>>> fora basic LAMP setup.
>>>
>>>
>>
>> If you say to the car dealer "I would like to buy
>> a cerise van" and the car dealer says "We don't
>> have cerise, how about red?" it makes no sense to
>> go to the coffee shop down the street and ask the
>> folks there "Why doesn't that car dealer have
>> cerise cars?"
>
> Your are trying to explain with an analogy, requiring abstraction, a problem you
> could understand with simple logic.

Why, yeees. Or even reading the actual words of
the actual original question, actually. Actually *read*,
I mean.

>>>>> No command 'php-config' found, did you mean:
>>>>> Command 'php-config5' from package 'php5-dev' (main)

Alastair <-- never owned a red van
Re: getting perl and php to talk to each other [message #180648 is a reply to message #180643] Fri, 08 March 2013 00:45 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/7/2013 3:43 PM, The Natural Philosopher wrote:
> On 07/03/13 19:09, alexd wrote:
>> Cal Dershowitz (for it is he) wrote:
>>
>>> Struggling.
>>>
>>> $ php-config --libs
>>> No command 'php-config' found, did you mean:
>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>> Command 'php-config5' from package 'php5-dev' (main)
>>> php-config: command not found
>>
>> I should think that anybody with a passing familiarity with package
>> management would be able to work out what this output is telling them.
>>
> a passing familiarity with package management is not a requirement for
> running PHP or posting in this NG.
>
> NOr is installation of php development files and utilities a requirement
> fora basic LAMP setup.
>
>

No, but trying to get two different languages working together takes
more expertise than just installing LAMP. Of course, it's nothing a
troll like you would understand.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: getting perl and php to talk to each other [message #180713 is a reply to message #180632] Thu, 14 March 2013 09:16 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 06:33 AM, Ben Morrow wrote:
>
> Quoth swisscheese(at)cfl(dot)rr(dot)com:
>> On 03/07/2013 01:53 AM, Cal Dershowitz wrote:
>>>
>>> Struggling.
>>>
>>> $ php-config --libs
>>> No command 'php-config' found, did you mean:
>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>> Command 'php-config5' from package 'php5-dev' (main)
>>> php-config: command not found
>>> $
>>
>> Try php-config5 as php-config is a link to php-config5. Here they
>> both reside in /usr/bin. If you are missing php-config link (it appears
>> so) then create it.
>
> Installing the php-dev package should have created this link:
> http://xrl.us/bomxwq .
>
> Ben
>

I can't tell what precisely is holding me back now. I do, for an
absolute fact, know that it is not due to a lack of OP spending time
trying to figure this stuff out as best he can.


$ cat phpini.sh



1 #!/bin/sh
2
3 set -e
4
5 #DEBHELPER#
6
7 if [ "$1" != "configure" ]; then
8 exit 0
9 fi
10
11 for i in php-config phpize; do
12 update-alternatives \
13 --install /usr/bin/"$i" $i /usr/bin/"$i"5 50 \
14 --slave /usr/share/man/man1/"$i".1.gz "$i".1.gz
/usr/share/man/man1/"$i"5.1.gz
15 done
16
17 exit 0
$ ./reg2.pl






1 #!/bin/sh

2
....


This primitive script is what I have for reg2.pl:

#!/usr/bin/perl -w
use strict;
use 5.010;
use File::Slurp;
my $in = 'phpini.sh';
my $out = 'php1.sh';
my @lines = read_file($in);

open( my $fh, ">", $out) or die $! ;
foreach (@lines) {
print $_ . "\n";
s/^\s+//;
s/^\d+//;
s/^\s+//;
print $fh $_;
}
close $fh;

....

$ cat php1.sh
#!/bin/sh
set -e
#DEBHELPER#
if [ "$1" != "configure" ]; then
exit 0
fi
for i in php-config phpize; do
update-alternatives \
--install /usr/bin/"$i" $i /usr/bin/"$i"5 50 \
--slave /usr/share/man/man1/"$i".1.gz "$i".1.gz
/usr/share/man/man1/"$i"5.1.gz
done
exit 0
$

....

$ ./php1.sh configure
update-alternatives: error: alternative path /usr/bin/php-config5
doesn't exist.
$

....

That has to say something there, doesn't it?
--
Cal
Re: getting perl and php to talk to each other [message #180714 is a reply to message #180648] Thu, 14 March 2013 09:19 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 04:45 PM, Jerry Stuckle wrote:
> On 3/7/2013 3:43 PM, The Natural Philosopher wrote:
>> On 07/03/13 19:09, alexd wrote:
>>> Cal Dershowitz (for it is he) wrote:
>>>
>>>> Struggling.
>>>>
>>>> $ php-config --libs
>>>> No command 'php-config' found, did you mean:
>>>> Command 'pdp-config' from package 'pd-pdp' (universe)
>>>> Command 'php-config5' from package 'php5-dev' (main)
>>>> php-config: command not found
>>>
>>> I should think that anybody with a passing familiarity with package
>>> management would be able to work out what this output is telling them.
>>>
>> a passing familiarity with package management is not a requirement for
>> running PHP or posting in this NG.
>>
>> NOr is installation of php development files and utilities a requirement
>> fora basic LAMP setup.
>>
>>
>
> No, but trying to get two different languages working together takes
> more expertise than just installing LAMP. Of course, it's nothing a
> troll like you would understand.
>

Get the motherfuck off my thread.

--
Cal
Re: getting perl and php to talk to each other [message #180715 is a reply to message #180642] Thu, 14 March 2013 09:23 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 12:09 PM, Henry Law wrote:
> On 07/03/13 19:09, alexd wrote:
>
>> I should think that anybody with a passing familiarity with package
>> management would be able to work out what this output is telling them.
>>
>
> ay, there’s the rub!
>

Rub? This is just getting tackled and not knowing why.
--
Cal
where to put the binaries was Re: getting perl and php to talk to each other [message #180716 is a reply to message #180643] Thu, 14 March 2013 10:11 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 12:43 PM, The Natural Philosopher wrote:

> a passing familiarity with package management is not a requirement for
> running PHP or posting in this NG.
>
> NOr is installation of php development files and utilities a requirement
> fora basic LAMP setup.
>
>

NP, I've been reading you for a while now. Did you give me the name of
a newsgroup where they consider webstuff ontopic?

I'm rather convinced that scripting languages are my meal ticket this
month, so much so that I'm making it happen with my rudimentary
webtools. This is what I call output:

http://merrillpjensen.com/food_4.html

This is a powerful medium, where one can intermix binaries and text. My
problem now is that it's not a discrete medium without me attending
endlessly to obfuscations with files that I would much just rather have
as themselves, and the only way you can see them is if php lets you with
an authentication level equal to my level of give a crap.

It's been a while since I did a source listing, so I would like to do
so, now that I can ask better questions.

In my line of work, I find myself taking a lot of pictures, because it
shows what I do for my clients. My clients are honest to God Amis whose
privacy is a matter for me to stake my integrity on, and I have enough
of them that I know that their preferences to privacy vary, depending
mostly on age, btw. Little bit on class. whatevs.

The rub is that I need to be able to show what I do to market the things
that I do. These are the scripts I'm using to pull it off now:

I run a bash script to handle the images that get chosen from my camera:

$ cat nikon_bash3.sh
#!/bin/bash

set -e
PARENTDIR='cleaning'
DIR='images1'
cd ${PARENTDIR}
mkdir -p $DIR
cp *.JPG $DIR
cd $DIR
ls -l
mogrify -resize 800x600! *
rename 'y/A-Z/a-z/' *.JPG
ls -l
cd ..
cd ..
pwd
sudo fredify2.sh
$

I have several versions of this. Very vanilla.

$ cd cleaning
$ cat food_ftp1.pl
#!/usr/bin/perl -w
use strict;
use 5.010;
use Net::FTP;
use HTML::Entities;
use File::Basename;
use Cwd;

# diamond bracket in paragraph mode declared at top scope
$/ = "";

## usage needs 1 arg from argv my_ftp

#identity and config
my $ident = 'my_ftp.txt';
my ( $config, $domain );
$config = do($ident);
unless ($config) {
die("read error: $!") if $!;
die("parse error: $@") if $@;
}
$domain = $config->{ $ARGV[0] };
die("unknown domain: $ARGV[0]") unless $domain;

# get name of directory
my $dir = cwd;
print "dir is $dir \n";
my $word = basename($dir);
print "word is $word \n";

# get files
my $path = "images1/";
my @files = <$path*>;
print " files are @files\n";

#dial up the server
my $ftp = Net::FTP->new( $domain->{domain}, Debug => 1, Passive => 1 )
or die "Can't connect: $@\n";
$ftp->login( $domain->{username}, $domain->{password} )
or die "Couldn't login\n";
$ftp->binary();

# get files from remote root that end in html:
my @remote_files = $ftp->ls();

# make unique .html choice
my @matching = map /${word}_(\d+)\.html/, @remote_files;
print "matching is @matching\n";
push( @matching, 0 );
@matching = sort { $a <=> $b } @matching;
my $winner = pop @matching;
my $newnum1 = $winner + 1;
my $word2 = "${word}_$newnum1";
print " new word is $word2\n";
my $html_file = "${word2}.html";
print "html file is $html_file\n";

#make directory in images to correspond

$ftp->cwd("images/")
or die "Cannot change working directory ", $ftp->message;
$ftp->mkdir("${word2}/")
or warn "Cannot create directory ", $ftp->message;
$ftp->cdup();

# create file for html stubouts
open( my $fh, '>', $html_file )
or die("Can't open $html_file for writing: $!");

my $header = "template_stuff/header1.txt";

# write in the header
open( my $gh, '<', $header ) or die("Can't open: $!");

while (<$gh>) {
print $fh $_;
}

my $h1 = 'Resolving conflicts';
my $h2 = 'and moving forward';
print $fh "<h1>$h1</h1>\n";
print $fh "<h2>$h2</h2>\n";

#create template outside loop

my $template = <<'TEMPLATE';
<img src="/images/%s"/>

<p>%s</p>
TEMPLATE

open my $CAPTIONS, "<", "food1.txt" or die "file not there\n";

$ftp->cwd("/images/${word2}/") or die "cwd failed $@\n";

# main control
for my $name (@files) {
print "name is $name\n";
my $remote_file = basename($name);
print "remote is $remote_file\n";
$ftp->put( $name, $remote_file ) or die "put failed $!\n";

# captions
my $caption = <$CAPTIONS>;
$caption = encode_entities($caption);
printf $fh $template, "${word2}/" . $remote_file, $caption;
}

# write in the footer
my $footer = "template_stuff/footer1.txt";
open( my $hh, '<', $footer )
or die("Can't open: $!");

while (<$hh>) {
print $fh $_;
}

close $fh;
$ftp->pwd();
$ftp->ls();
$ftp->cdup() or die "cdup failed $@\n";
$ftp->cdup() or die "cdup failed $@\n";
$ftp->put($html_file) or die "put failed $@\n";

$

This has so far been my home-cooked perl version of static web dev, but
I want to see if php can obviate all the go***a%n filing-about that you
have to do to maintain the privacies of the the binaries shown. These
images are my shack so I don't care so much anymore. I also use this
tool chain to lay down the law with people a bit; it's a very direct medium:

http://merrillpjensen.com/cleaning_1.html

Q1) How do I design a website where the binaries aren't there for the
taking unless php thinks you have done some act of authentication to see
them?

Q2) What's a good first book for php?
--
Cal
Re: getting perl and php to talk to each other [message #180717 is a reply to message #180624] Thu, 14 March 2013 10:28 Go to previous messageGo to next message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/07/2013 03:28 AM, SwissCheese wrote:
> On 03/07/2013 01:53 AM, Cal Dershowitz wrote:
>> On 03/05/2013 02:06 PM, Ben Morrow wrote:
>>>
>>> Quoth Cal Dershowitz <cal(at)example(dot)invalid>:
>>>> [x-posted to clp.misc]
>>> [...]
>>>>
>>>> This article has me convinced that I want perl and php able to deal
>>>> with
>>>> each other:
>>>>
>>>> http://www.linuxjournal.com/article/9282?page=0,1
>>>
>>> Why on Earth would you want to do that? Seriously, I can't think of any
>>> situation where mixing PHP and Perl is easier than just writing in Perl
>>> in the first place.
>>>
>>> Note that the Perl in that article (or at least, the first page, which
>>> was all I read) is pretty bad:
>>>
>>> - use of global filehandles, unnecessary since 2000,
>>> - use of Thread.pm, deprecated since 2002,
>>> - use of threads at all for such a trivial problem,
>>> - using rindex and substr rather than pattern matching,
>>> - using backticks instead of system(),
>>> - using PHP to talk to a database, when Perl's DBI module is
>>> considerably better than PHP's rather random database functions.
>>>
>>> I don't know PHP well enough to comment on it, but I wouldn't be
>>> surprised if the PHP code was just as bad (for instance, I understand
>>> PHP has a saner database interface these days; I don't know if it
>>> existed in 2007, though).
>>>
>>>> so far so good, and then this thing which I've seen in the literature:
>>>>
>>>> using php_config 'php-config'
>>>> Can't exec "php-config": No such file or directory at Makefile.PL
>>>> line 55.
>>>> Failed to find the 'php-config' executable. Make sure you have PHP and
>>>> PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
>>>> line 55.
>>>> ...
>>>>
>>>> bla bla bla do not pass Go. Right now I have a default installation.
>>>>
>>>> Simple question: What types of things can I get configured with
>>>> php-config? envelope data available? ftp data?
>>>
>>> php-config is a program installed with php, which tells other programs
>>> how php was installed. For instance, on my system
>>>
>>> ~% php-config --libs
>>> -lcrypt -lcrypt -lpcre -lm -lxml2 -lz -liconv -lm -lcrypt -lcrypt
>>> ~% php-config --includes
>>> -I/usr/local/include/php -I/usr/local/include/php/main
>>> -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
>>> -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
>>> ~%
>>>
>>> and so on. If you've installed php properly (including any required
>>> development packages, if you're using a package system), you should have
>>> a php-config executable somewhere. Make sure it's in your PATH before
>>> running Makefile.PL.
>>
>> Struggling.
>>
>> $ php-config --libs
>> No command 'php-config' found, did you mean:
>> Command 'pdp-config' from package 'pd-pdp' (universe)
>> Command 'php-config5' from package 'php5-dev' (main)
>> php-config: command not found
>> $
>
> Try php-config5 as php-config is a link to php-config5. Here they
> both reside in /usr/bin. If you are missing php-config link (it appears
> so) then create it.
>

swiss,

Can you elaborate?
--
Cal
Re: randomly sorting files in php [message #180718 is a reply to message #180593] Thu, 14 March 2013 10:39 Go to previous messageGo to previous message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma: 0
Member
On 03/04/2013 02:45 AM, Captain Paralytic wrote:
> On Mar 1, 1:49 am, Cal Dershowitz <c...@example.invalid> wrote:
>> Hello ng,
>>
>> I've got a working localhost and a couple php scripts that run so far,
>> so I wanted to see what types of things I can do and cannot do. This is
>> by no means clear to me to me now.
>>
>> What I have is a collection of my own music files that I have put in the
>> path of where localhost is looking for things; with my default install,
>> that is /var/www.
>>
>> I wrote a bash script to export the files off my mp3 player, because
>> neither my gf nor I who bought these things can figure how to make them
>> play randomly. Yes we have achieved a certain age, where determination
>> makes up for a lot.
>>
>> $ cat music1.sh
>> #!/bin/bash
>>
>> set -e
>> FROM='CCE0-705F'
>> DIR='music1'
>> mkdir -p $DIR
>> cp $FROM/*.wma $DIR/
>> cp $FROM/*.mp3 $DIR/
>> cd $DIR
>> ls -l
>> exit 0
>> $
>>
>> So does php have a way to do this that is as simple as it might be in
>> perl, for example?
>> --
>> Cal
>
> Do you know what order the mp3 player uses to decide the order of
> play? If for instance it plays in alphabetical order of file name,
> then the only way to get them played randomly is to rename them. On
> the other hand it could be based on the order in which they are copied
> to the device.
>

there's a USER.PL there, empty.

playlist perl Idunno.
--
Cal
Pages (2): [1  2    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to avoid the use of session variables in this script
Next Topic: all done
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 23:17:15 GMT 2024

Total time taken to generate the page: 0.02826 seconds