Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003

    Unanswered: Someone please ans this doubt!!

    Hi all

    I have been posting many questions here but havent recieved a reply for most of them lately.
    Anyway wanted to know that in perl if i do something like

    system(dos command)
    then is there any way i can store the result returned to the prompt in an external text file for later use.
    for eg if i say system("dir c:") and i want the result to be stored in any external text file. is it possible..

    While executing isql command its possible by saying
    open(ISQL,"isql -s servername blah blah blah..")

    then @array has the whole result saved but can a similar thing be done for any other dos command?
    please please let me know its v v urgent

    You try and try again..but then give up, there's no sense in being a complete fool about it!!!

  2. #2
    Join Date
    Sep 2002
    Germany, near Aachen
    Easiest way is to use backticks:

    my @files = `dir c:`;

    Those quotes are the ones that lean to the left. The string is executed as system command and the output is stored in the array.

    perldoc perlfaq8 - Why can't I get the output of a command with system()?

  3. #3
    Join Date
    Feb 2003


    Use the redirect symbol to output to a file...


    system("dir c: > output.txt");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts