Export CMD results on a host through ip?

0

Is it possible to export the command prompt session result to a host over the network?

AlGallaf

Posted 2012-04-18T13:28:25.550

Reputation: 135

What operating system? And what do you want to happen to those results on the remote host - save them to a file? Pass them as arguments to a new process? Perhaps you could describe in a bit more detail what exactly you're trying to achieve? – Indrek – 2012-04-18T13:32:45.840

1.Windows 7 2.Save the results in a file on a windows machine over the network 3.No – AlGallaf – 2012-04-18T13:34:30.470

Answers

1

If the location where you want to save the file is accessible over the network, then you can simply use command redirection to send the output of your command directly to a file. For instance (with the dir command):

dir > \\SERVER\Path\file.txt

If you want to do this multiple times and append the output to the same file each time, use >> instead of >.

Edit: if the remote machine requires credentials other than those of the logged in user, try this:

net use \\SERVER\Path /user:SERVER\username password
your_command > \\Server\Path\file.txt
net use \\Server\Path /d

The first line connects to the shared folder using the given username and password, and the third line disconnects.

Indrek

Posted 2012-04-18T13:28:25.550

Reputation: 21 756

Thank you. What if the Windows machine requires credentials? – AlGallaf – 2012-04-18T13:40:46.360

@looi76 By default it should attempt to use the credentials of the currently logged in user, so you could try creating a user with the same credentials on the remote host and giving it the nexessary permissions. But if you need to use different credentials, see the edit in my answer. – Indrek – 2012-04-18T14:02:39.330