Getting feedback from cmd.exe

Following works on my Linux machines- watch for the space before '/all'.
M$     = "ipconfig /all"

cmd$    = IM$ + " > test.txt"

run cmd$

open "test.txt" for input as #fi
    f$ =input$( #fi, lof( #fi))
close #fi

print f$
end