asha_mail has asked for the wisdom of the Perl Monks concerning the following question:

Example:

$a=`dd if=/dev/$cmd of=/dev/null bs=4096 count=2 > ddlog.txt 2>&1`;
$cmd is variable used to give user input from drop down box. At run time if i give
$a=`dd if=/dev/ram0 of=/dev/null bs=4096 count=2 > ddlog.txt 2>&1`; the output is printed on terminal but i want it to display in textbox.

Replies are listed 'Best First'.
Re: Adding DD Unix command in Perl
by JavaFan (Canon) on Dec 09, 2011 at 10:47 UTC
    I'm a bit surprised you are saying the output is printed on the terminal. You're redirecting both STDOUT and STDERR to ddlog.txt. Perphaps your implementation of dd writes to the terminal, but if I execute your command, the output gets written to ddlog.txt.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Adding DD Unix command in Perl
by pvaldes (Chaplain) on Dec 09, 2011 at 12:57 UTC

    wrong idea, this does nothing usefull

    if=/dev/ram0 of=/dev/null

    Don't mess with dd unless you know what are you doing, this is a potentially very dangerous command in the wrong hands. You'll need to run your perl script as root in any case, a double bad idea.

    if you want to overwrite the ram with null values, you need to do THIS instead

    if=/dev/null of=/dev/ram0

    Don't claim to me if you finish deleting your entire filesystem and personal files with dd by mistake.

      How to pass perl variable to unix command?

        The question really is... What are you trying to do?
        Why are you asking how to do something you've already done? You can pass arguments to a unix utility by building a shell command like you already did.