Unable to view log files on remote server in another domain

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Unable to view log files on remote server in another domain

#1 Post by tbharber » 05 Jan 2014 22:26

Hey All,

I am working on a script to view log files on a remote server in another domain and am running into an issue. Below is what I get when I try to do this...

Code: Select all

runas /user:a083138@proghsz "type \\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin\RuleEngine.txt | find ERROR"

Enter the password for a083138@proghsz:

Attempting to start type \\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin\RuleEngine.txt as user "a083138@proghsz" ...

RUNAS ERROR: Unable to run - type \\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin\RuleEngine.txt
1787: The security database on the server does not have a computer account for this workstation trust relationship.




I am at a loss for how to work around this. I know some built in applications will work just fine. "systeminfo" for example works just fine with no issues...

Code: Select all

systeminfo /u proghsz\a083138 /p xxxxxx /s scnice01



An anyone think of a workaround that will allow me to view the files as shown above?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#2 Post by foxidrive » 05 Jan 2014 22:38

Your path has spaces in it. Test if a txt file can be typed in a folder where there are no spaces.

You may need to use "%comspec% /c type path\filename.txt"

tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Re: Unable to view log files on remote server in another dom

#3 Post by tbharber » 05 Jan 2014 22:54

No luck either way with a text file with no spaces...


Code: Select all

runas /user:a083138@proghsz "type \\scnice01\c$\text.txt"
Enter the password for a083138@proghsz:
Attempting to start type \\scnice01\c$\text.txt as user "a083138@proghsz" ...

RUNAS ERROR: Unable to run - type \\scnice01\c$\text.txt
1787: The security database on the server does not have a computer account for this workstation trust relationship.




runas /user:a083138@proghsz "%comspec% /c type \\scnice01\c$\text.txt"
Enter the password for a083138@proghsz:
Attempting to start C:\Windows\system32\cmd.exe /c type \\scnice01\c$\text.txt as user "a083138@proghsz" ...

RUNAS ERROR: Unable to run - C:\Windows\system32\cmd.exe /c type \\scnice01\c$\text.txt
1787: The security database on the server does not have a computer account for this workstation trust relationship.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#4 Post by foxidrive » 05 Jan 2014 22:57

Try this to see if it is cmd that is the issue.

"%comspec% /c echo abc"

tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Re: Unable to view log files on remote server in another dom

#5 Post by tbharber » 05 Jan 2014 23:02

That works just fine...

Code: Select all

%comspec% /c echo abc
abc

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#6 Post by foxidrive » 05 Jan 2014 23:51

I'm out of ideas.

tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Re: Unable to view log files on remote server in another dom

#7 Post by tbharber » 06 Jan 2014 02:05

The only workaround I have found so far is to use the "net use" command to map the folder to a drive letter...

Code: Select all

if exist l:\ (net use l: /d  > nul)

net use l: "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin" passwordhere /user:proghsz\a083138 > nul

findstr /L "ERROR" l:\RuleEngine.txt

net use l: /d  > nul



This works but I'm not a fan of how messy it is. I am making the assumption that the users drive letter (L in this case) is free to use and if not the script will not work. I suppose I could make a loop to look for each drive letter that is free but again this is messy and a lot of extra work since all I want to do is look at the contents of a file.

If anyone has any more suggestions I would love to hear them.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Unable to view log files on remote server in another dom

#8 Post by Squashman » 06 Jan 2014 07:18

I am not at work to test but I am wondering if the TYPE command supports UNC paths.

Other options:

As seen on StackOverFlow
http://stackoverflow.com/questions/3716 ... batch-file

Code: Select all

net use * "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin" passwordhere /user:proghsz\a083138

or

Code: Select all

net use "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin" passwordhere /user:proghsz\a083138


I would have to test when I get to work but the 2nd option may allow you to then use PUSHD to assign the drive letter and change to that paths directory.

Code: Select all

pushd "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin"

This would normally just assign a drive letter and immediately put you into that drive letter.

And this isn't messy at all.

Code: Select all

net use * \\server\share
for /f "tokens=2" %%i in ('net use ^| find "\\server\share"') do set netdrive=%%i
echo %netdrive% has been mapped

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#9 Post by foxidrive » 06 Jan 2014 08:13

Squashman has nailed this I think.

pushd with a UNC path maps a temporary drive letter that is free, performs the task and the popd unmaps it.

So this should work:

Code: Select all

pushd "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin"
type "RuleEngine.txt" | find ERROR
popd


It may require authentication - I hadn't thought of that.
pushd has no way of supplying credentials

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Unable to view log files on remote server in another dom

#10 Post by Squashman » 06 Jan 2014 09:05

foxidrive wrote:It may require authentication - I hadn't thought of that.
pushd has no way of supplying credentials

I think if you use the net use with credentials first and then the PUSHD it should work.

Code: Select all

net use "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin"  /user:proghsz\a083138 passwordhere
pushd "\\scnice01\d$\Program Files\NICE Systems\Applications\ServerBin"

According to the stackoverflow post you don't need to specify the driver letter at all and this should get the credentials going.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#11 Post by foxidrive » 06 Jan 2014 09:27

net use requires a * or a drive letter next, AIUI.

If you use * it will assign a free drive letter, and then maybe the pushd will work - that needs to be tested, and I don't have a LAN to check it atm.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Unable to view log files on remote server in another dom

#12 Post by Squashman » 06 Jan 2014 09:33

I just tested this and it worked for me.

Code: Select all

H:\>net use "\\Server\E$\BatchFiles" /user:domain\squashman password
The command completed successfully.


H:\>pushd "\\Server\E$\BatchFiles"

Z:\BatchFiles>dir
 Volume in drive Z is Data
 Volume Serial Number is F0A8-D2F3

 Directory of Z:\BatchFiles

12/16/2013  12:34 PM    <DIR>          .
12/16/2013  12:34 PM    <DIR>          ..
08/17/2012  11:36 AM               434 MybatFile.bat

Z:\BatchFiles>type \\server\E$\BatchFiles\Mybatfile.bat
cd \
J:

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Unable to view log files on remote server in another dom

#13 Post by Squashman » 06 Jan 2014 09:35

You don't even need the PUSHD because TYPE can then use the UNC path.

Code: Select all

Z:\BatchFiles>popd

H:\>type \\Server\E$\BatchFiles\Mybatfile.bat
cd \
J:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to view log files on remote server in another dom

#14 Post by foxidrive » 06 Jan 2014 09:37

Good one.

We'll have to see how tbharber goes in his tests.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Unable to view log files on remote server in another dom

#15 Post by Squashman » 06 Jan 2014 09:39

Don't forget to delete the mapping.

Code: Select all

H:\>net use "\\server\E$\BatchFiles" /delete
\\server\E$\BatchFiles was deleted successfully.

Post Reply