Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-07

Capturing the output from a command using TPorcess

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi All,
I hope this question is going to make sense.
I am trying to obtain the MAC Address of a remote PC, using psexec \\pcname and running the command "ipconfig /all".
If I run the psexec command from my machine via a command prompt, ipconfig /all is successfully run on the remote machine, and I can see it's MAC address, however, if I run it via TProcess, in Lazarus, the output I get from TProcess is the output from psexec (successfully run and exited with error code 0) rather than the output from ipconfig. How can I code TProcess, so that it shows me the output from the "ipconfig /all" command instead?

I hope that makes sense?

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150720/c9e696f8/attachment.html>

Reply by email

Frederic Da Vitoria
to Richard Mace

2015-07-20 21:41 GMT+02:00 Richard Mace :

Show quoted text 13 lines
Hi All, I hope this question is going to make sense. I am trying to obtain the MAC Address of a remote PC, using psexec \\pcname and running the command "ipconfig /all". If I run the psexec command from my machine via a command prompt, ipconfig /all is successfully run on the remote machine, and I can see it's MAC address, however, if I run it via TProcess, in Lazarus, the output I get from TProcess is the output from psexec (successfully run and exited with error code 0) rather than the output from ipconfig. How can I code TProcess, so that it shows me the output from the "ipconfig /all" command instead?

Hello,

This is not exactly what you asked for, but you could simply redirect the output with something like "ipconfig /all > ipconfig..txt" then read the contents of ipconfig.txt (or whatever name you gave to the output file). You must take care where you put the output file, though: you must have the rights to write in that folder.

Of course my solution is only a quick trick, the answer to your question would be much cleaner and much more interesting.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150720/14509216/attachment.html>

Reply by email

Richard Mace
to Bart

On 20 Jul 2015 23:30, "Bart"

> How can I code TProcess, so that it shows me the output from the

"ipconfig

> /all" command instead?

http://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output

Thanks Bart, but I have already read that page and my code is based on that. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150721/568cd810/attachment.html>

Reply by email

Richard Mace
to Frederic Da Vitoria: 2015-07-20 21:41 GMT+02:00 Richard Mace : This is not exactly what you asked for, but you…
"Frederic Da Vitoria" wrote
2015-07-20 21:41 GMT+02:00 Richard Mace > How can I code TProcess, so that it shows me the output from the

"ipconfig /all" command instead?

Show quoted text 5 lines
Hello, This is not exactly what you asked for, but you could simply redirect the

output with something like "ipconfig /all > ipconfig..txt" then read the contents of ipconfig.txt (or whatever name you gave to the output file). You must take care where you put the output file, though: you must have the rights to write in that folder.

Of course my solution is only a quick trick, the answer to your question

would be much cleaner and much more interesting.

Hi Frederic, that's a good idea and I hadn't thought of that work around. I'll give it a go

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150721/62041fee/attachment.html>

Reply by email

shoKwave
to Richard Mace: I hope this question is going to make sense. I am trying to obtain the MAC Address of a…

Hi,

instead of using "psexec" you could try "getmac /S <pcname>".

Hope this helps.

Ingo

Richard Mace wrote 22 lines
Hi All, I hope this question is going to make sense. I am trying to obtain the MAC Address of a remote PC, using psexec \\pcname and running the command "ipconfig /all". If I run the psexec command from my machine via a command prompt, ipconfig /all is successfully run on the remote machine, and I can see it's MAC address, however, if I run it via TProcess, in Lazarus, the output I get from TProcess is the output from psexec (successfully run and exited with error code 0) rather than the output from ipconfig. How can I code TProcess, so that it shows me the output from the "ipconfig /all" command instead? I hope that makes sense? Richard -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email