FAQ
Hello,

I want to give a date (the year, the day, the hour and the minute) to a
file. So, I use localtime function. But I don't understand how to use
localtime (after reading the documentation on this function). Can you
help me with this function?

Next, I want to use a shell command, so I use the Shell function[2], and
I must use the 'mysqldump' command :

mysqldump -u root -p *** --all-databases > $FILE

How could I use this command with the Shell function ?

[1] : http://perldoc.perl.org/functions/localtime.html
[2] : http://perldoc.perl.org/Shell.html

I'm a beginner with perl... :-)

Thanks !

--
Shams Fantar (http://snurf.info)

Search Discussions

  • Jeff Pang at Sep 3, 2007 at 1:53 pm
    try the POSIX::strftime,this use the same datetime format as shell's
    date command.

    perl -e '
    use POSIX qw/strftime/;
    print strftime("%y%m%d %H:%M",localtime); '

    070903 21:51

    2007/9/3, Shams Fantar <sfantar@snurf.info>:
    Hello,

    I want to give a date (the year, the day, the hour and the minute) to a
    file. So, I use localtime function. But I don't understand how to use
    localtime (after reading the documentation on this function). Can you
    help me with this function?

    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE

    How could I use this command with the Shell function ?

    [1] : http://perldoc.perl.org/functions/localtime.html
    [2] : http://perldoc.perl.org/Shell.html

    I'm a beginner with perl... :-)

    Thanks !

    --
    Shams Fantar (http://snurf.info)


    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/

  • Shams Fantar at Sep 3, 2007 at 2:13 pm

    Jeff Pang wrote:
    try the POSIX::strftime,this use the same datetime format as shell's
    date command.

    perl -e '
    use POSIX qw/strftime/;
    print strftime("%y%m%d %H:%M",localtime); '

    070903 21:51
    Okay. All right.

    use POSIX qw(strftime);
    my $date1 = strftime("%y/%m/%d %H:%M",localtime);
    my $FILE = "/home/scripts/backups_db/db-$date1.sql";
    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE

    How could I use this command with the Shell function ?

    [2] : http://perldoc.perl.org/Shell.html
    And for this question ?

    Regards,

    --
    Shams Fantar (http://snurf.info)
  • Jeff Pang at Sep 3, 2007 at 2:17 pm

    2007/9/3, Shams Fantar <sfantar@snurf.info>:
    Jeff Pang wrote:
    try the POSIX::strftime,this use the same datetime format as shell's
    date command.

    perl -e '
    use POSIX qw/strftime/;
    print strftime("%y%m%d %H:%M",localtime); '

    070903 21:51
    Okay. All right.

    use POSIX qw(strftime);
    my $date1 = strftime("%y/%m/%d %H:%M",localtime);
    my $FILE = "/home/scripts/backups_db/db-$date1.sql";
    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE

    How could I use this command with the Shell function ?

    [2] : http://perldoc.perl.org/Shell.html
    And for this question ?
    What question?running shell command in perl script?
    You may need the system call.
    system('command','arg1','arg2',...)
  • Shams Fantar at Sep 3, 2007 at 2:45 pm

    Jeff Pang wrote:
    2007/9/3, Shams Fantar <sfantar@snurf.info>:
    Jeff Pang wrote:
    try the POSIX::strftime,this use the same datetime format as shell's
    date command.

    perl -e '
    use POSIX qw/strftime/;
    print strftime("%y%m%d %H:%M",localtime); '

    070903 21:51
    Okay. All right.

    use POSIX qw(strftime);
    my $date1 = strftime("%y/%m/%d %H:%M",localtime);
    my $FILE = "/home/scripts/backups_db/db-$date1.sql";

    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE

    How could I use this command with the Shell function ?

    [2] : http://perldoc.perl.org/Shell.html

    And for this question ?
    What question?running shell command in perl script?
    You may need the system call.
    system('command','arg1','arg2',...)
    Yes, or exec().

    Regards,

    --
    Shams Fantar (http://snurf.info)
  • Adriano Ferreira at Sep 3, 2007 at 6:38 pm

    On 9/3/07, Shams Fantar wrote:
    Hello,

    I want to give a date (the year, the day, the hour and the minute) to a
    file. So, I use localtime function. But I don't understand how to use
    localtime (after reading the documentation on this function). Can you
    help me with this function?

    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE
    The Shell module may be used to make this system call to the utility
    'mysqldump' transparent to the code. Like this:

    use Shell qw( mysqldump );
    my $content = mysqldump( qw( -u root -p *** --all-databases ) );

    The mysqldump() function gets all the output produced by the utility
    'mysqldump'. But there's very much to be gained by using Shell. And
    unless your script is very small, it's not such a good idea to use it
    (the Shell core module).
    How could I use this command with the Shell function ?

    [1] : http://perldoc.perl.org/functions/localtime.html
    [2] : http://perldoc.perl.org/Shell.html

    I'm a beginner with perl... :-)

    Thanks !
    Welcome to Perl.

    Best regards,
    Adriano Ferreira
    --
    Shams Fantar (http://snurf.info)


    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/

  • Shams Fantar at Sep 3, 2007 at 6:47 pm

    Adriano Ferreira wrote:
    On 9/3/07, Shams Fantar wrote:

    Hello,

    I want to give a date (the year, the day, the hour and the minute) to a
    file. So, I use localtime function. But I don't understand how to use
    localtime (after reading the documentation on this function). Can you
    help me with this function?

    Next, I want to use a shell command, so I use the Shell function[2], and
    I must use the 'mysqldump' command :

    mysqldump -u root -p *** --all-databases > $FILE
    The Shell module may be used to make this system call to the utility
    'mysqldump' transparent to the code. Like this:

    use Shell qw( mysqldump );
    my $content = mysqldump( qw( -u root -p *** --all-databases ) );

    The mysqldump() function gets all the output produced by the utility
    'mysqldump'. But there's very much to be gained by using Shell. And
    unless your script is very small, it's not such a good idea to use it
    (the Shell core module).
    Okay, there are thus many solutions. ;-)
    How could I use this command with the Shell function ?

    [1] : http://perldoc.perl.org/functions/localtime.html
    [2] : http://perldoc.perl.org/Shell.html

    I'm a beginner with perl... :-)

    Thanks !
    Welcome to Perl.

    Thank you very much !
    Best regards,
    Adriano Ferreira
    --
    Shams Fantar (http://snurf.info)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedSep 3, '07 at 1:35p
activeSep 3, '07 at 6:47p
posts7
users3
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase