June 16, 2004 at 4:52 am
Hi,
Any idea why when using xp_cmdshell to write to a text file (Exec master..xp_cmdShell 'ECHO this is test text >> C:\test_06152004.txt'), it doesnt write to the file at all.
This is the case when i execute the command in MSSQL installed in win2k server.
But this works fine in MSSQL installed in win2k and win xp.
Also, if i execute the above in isqlw of MSSQL installed on win2k server) with a folder structure as - Exec master..xp_cmdShell 'ECHO this is test text >> C:\test\test_06152004.txt' this gives a message that system file path not found!
But when i execute the command as - Exec master..xp_cmdShell 'ECHO this is test text >> test_06152004.txt', and then execute the command - Exec master..xp_cmdShell 'dir tes*.*' - it shows that the previous command has created the file (test_06152004.txt) in C:\WINNT\system32 - but when i navigate to the folder (C:\WINNT\system32) either in the win explorer or cmd prompt and search for the file, i cannot locate the file at all!!
Some really strange behaviour here..
June 16, 2004 at 7:00 am
You are looking in the SQL Server's C:\WINNT\system32 directory, and not your own local C:\WINNT\system32, right?
Cheers,
- Mark
June 17, 2004 at 1:52 am
Gawd! I'm a dummy!
Mark, thanks for pointing out the obvious.. I was actually looking at C:\WINNT\system32 of my machine.. the sql server is in a different box and I never even thought that the command is executing on the box where SQL server is installed!
Sorry for wasting time folks! Now I do see that the text files are being created in the sql server.
Thanks again Mark.
June 17, 2004 at 2:09 am
Glad we sorted that out before you got frustrated and tried out the "format" command.
Cheers,
- Mark
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply