Leo Susanto | 7 Apr 2011 00:11
Picon

'sprintf' is not recognized as an internal or external command, operable program or batch file.

Hi,

I am trying to make the makefile with the option of inserting
testuser, testpassword and testhost into "perl.exe Makefile.PL"
command line, but I keep getting "'sprintf' is not recognized as an
internal or external command, operable program or batch file."

C:\CPANTesters\Perl5.10.0\cpan\build\DBD-mysql-4.018-d8v5HG>perl.exe
Makefile.PL INSTALLDIRS=site --testuser=cpantesters
--testpassword=cpantesters --testhost=localhost
'sprintf' is not recognized as an internal or external command,
operable program or batch file.
Problem running C:\CPANTE~1\bin\MYSQL-~1.11-\bin\MYSQLA~1.EXE - aborting ...

I trace it down and this is the part of Makefile.PL that doesn't work.

    my $v;
    if ( defined $opt->{'testuser'} and defined $opt->{'testpassword'}) {
        $v = qx( sprintf('%s --user=%s --password=%s version',
$mysqladmin , $opt->{'testuser'}, $opt->{'testpassword'}) );
    } else {
        $v = qx($mysqladmin version);
    }

Taking the sprintf() out of qx() works.

    my $v;
    if ( defined $opt->{'testuser'} and defined $opt->{'testpassword'}) {
        my $line = sprintf('%s --user=%s --password=%s version',
$mysqladmin , $opt->{'testuser'}, $opt->{'testpassword'});
(Continue reading)

Selke, Gisbert W. | 7 Apr 2011 10:12
Picon

AW: 'sprintf' is not recognized as an internal or external command, operable program or batch file.

Hi Leo --

The qx operator, according to the Perl docs, takes "A string which is (possibly) interpolated and then
executed as a system command with /bin/sh or its equivalent". So you're asking your shell to do a sprintf.
Since you seem to be working under Windows, this is equivalent to you typing "sprintf(blah)" at the
Windows (aka "DOS") command prompt (try it!). The error message you get has nothing to do with Perl at all,
it's just that you're asking your shell something that the shell does not know how to do.

In any case, it's probably not what you want to do anyway. What you want to do is what you describe in the second
part of your mail. And that does work indeed, as you say. 

\Gisbert

> -----Ursprüngliche Nachricht-----
> Von: Leo Susanto [mailto:leosusanto <at> gmail.com] 
> Gesendet: Donnerstag, 7. April 2011 00:11
> An: perl <at> lists.mysql.com
> Betreff: 'sprintf' is not recognized as an internal or 
> external command, operable program or batch file.
> 
> 
> Hi,
> 
> I am trying to make the makefile with the option of inserting
> testuser, testpassword and testhost into "perl.exe Makefile.PL"
> command line, but I keep getting "'sprintf' is not recognized as an
> internal or external command, operable program or batch file."
> 
> C:\CPANTesters\Perl5.10.0\cpan\build\DBD-mysql-4.018-d8v5HG>perl.exe
> Makefile.PL INSTALLDIRS=site --testuser=cpantesters
(Continue reading)

David Nicol | 8 Apr 2011 17:49
Picon
Gravatar

Re: 'sprintf' is not recognized as an internal or external command, operable program or batch file.

looks like you found a perfectly workable solution. Here's a more
complex way to do it without a named temporary variable:

      $v = qx(  <at> {[sprintf('%s --user=%s --password=%s version',
$mysqladmin , $opt->{'testuser'}, $opt->{'testpassword'}) ]}  )

That's an instance of

    qq/   <at> {[    code goes here     ]}  /

which is a very handy idiom in my experience, except of course when
you want to run the code in scalar (not array) context, in which case
the approach can be adapted in any of several ways, but usually at
that point I'll use a named temporary.

On Wed, Apr 6, 2011 at 5:11 PM, Leo Susanto <leosusanto <at> gmail.com> wrote:

> [ Huh? ]
>        $v = qx( sprintf('%s --user=%s --password=%s version',
> $mysqladmin , $opt->{'testuser'}, $opt->{'testpassword'}) );
> [ doesn't DWIM.]

-- 
"If people let the government decide what foods they eat and what
medicines they take, their bodies will soon be in as sorry a state as
the souls who live under tyranny." -Thomas Jefferson (1778) (via Paleo
Approved fb feed)

--

-- 
MySQL Perl Mailing List
(Continue reading)


Gmane