June 8, 2011 at 11:27 pm
Hi all,
I have some information(in a text file) in c:\ drive in each server,and we have like 100 servers.I would like to get the info in c:\ drive of all the 100 servers into one text file in a jump server using command prompt.Please suggest me a script in command prompt to get all the info.I am trying to use a for loop here.
Thanks,in advance
June 10, 2011 at 5:12 am
You should ask some windows admin..
June 10, 2011 at 5:39 am
Try to use sqlcmd and bcp the values from the files in the C folder
M&M
June 10, 2011 at 7:28 am
Sounds to me like a job for powershell.
June 10, 2011 at 8:18 am
mohammed moinudheen (6/10/2011)
Try to use sqlcmd and bcp the values from the files in the C folder
vultar (6/10/2011)
Sounds to me like a job for powershell.
Do either of you have a solution for the real problem here? Automatically detecting the names of over 100 servers? If so, I'd love to see it.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 10, 2011 at 8:53 am
I am not sure this fits the bill, but check this link out and see if you can tweak things out.
http://www.scarydba.com/2010/10/18/powershell-is-really-easy-if-you-know-what-youre-doing/
June 10, 2011 at 10:57 am
Jeff Moden (6/10/2011)
mohammed moinudheen (6/10/2011)
Try to use sqlcmd and bcp the values from the files in the C foldervultar (6/10/2011)
Sounds to me like a job for powershell.Do either of you have a solution for the real problem here? Automatically detecting the names of over 100 servers? If so, I'd love to see it.
No, just a thought really.
M&M
June 10, 2011 at 4:38 pm
Just a suggestion as well. The original post doesn't mention anything about the need to automatically detect the names of over 100 servers..
June 10, 2011 at 4:58 pm
mnagasrikanth219 (6/8/2011)
Hi all,I have some information(in a text file) in c:\ drive in each server,and we have like 100 servers.I would like to get the info in c:\ drive of all the 100 servers into one text file in a jump server using command prompt.Please suggest me a script in command prompt to get all the info.I am trying to use a for loop here.
Thanks,in advance
Do you have a list of the servers that you're looking to ping? If so, how is it stored and being fed into your for loop?
Are each of these files pathed or are they just in the Root of C? Do they all have the same name?
If a file doesn't exist, what's the expectation?
You say 'into one text file', are you looking to create one massive text file from the results of all these or centralize these text files? If you're looking to toss them into a single file, how will you know where they came from? If you're bringing them in as multiple files, are you looking to rename them so you don't overwrite them?
You will need to provide a much more detailed scenario of exactly what you're doing here if we are to help you beyond very simple suggestions, as was mentioned earlier.
Regarding finding your servers:
SQLCMD -L (which finds active, 'advertising' servers, and is faulty. Thomas LaRock says it better then I: http://thomaslarock.com/2009/12/finding-servers-on-your-network/), NetServerEnum, or some secondary methods.
This link for example walks through using ODBC as a detector: http://www.codeproject.com/KB/database/LocatingSql.aspx
In particular on that link to Thomas LaRock's page go to the discussion for a selection of tools being reviewed.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
June 10, 2011 at 5:18 pm
A couple hints.
First, an admin can make a connection to any machine with the C$ share. So if you had a server called "SQL01", you could easily do this:
type \\SQL01\c$\MyTextFile.txt
which will list the text file. You could pipe that to a file with
type \\SQL01\c$\MyTextFile.txt > myfile.txt
or append it to an existing file with
type \\SQL01\c$\MyTextFile.txt >> myfile.txt
Now you need a way to hit 100 servers. A few people have mentioned the issue of finding them. There is a FOR command in DOS, or what I'd recommend is that you read up on Powershell and learn how to loop a list of servers there. It's a better skill to have and you can easily pipe the information to another file with it.
here's a quick hint: http://technet.microsoft.com/en-us/library/ee176843.aspx
June 15, 2011 at 7:37 pm
vultar (6/10/2011)
Just a suggestion as well. The original post doesn't mention anything about the need to automatically detect the names of over 100 servers..
Absolutely true. But I also didn't see any code come out of anyone if a list of servers were known. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply