Hello,
I am trying to use xm_cmdshell to create and populate a .txt file with the following data:
username
password
cd notindexed
put date.zip
bye
I can add multiple rows to my text file with the following:
<code>
exec master..xp_cmdshell '>c:\temp\ft.txt echo username'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo password'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo cd notindexed'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo put date.zip'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo bye'
</code>
However, is there a way I ran run it as one single script? I tried:
<code>
exec master..xp_cmdshell '>c:\temp\ft.txt echo username'
>>c:\temp\ft.txt echo password
>>c:\temp\ft.txt echo cd notindexed
>>c:\temp\ft.txt echo put date.zip
>>c:\temp\ft.txt echo bye'
</code>
and
<code>
declare @bigscript varchar(500)
set @bigscript =
'>c:\temp\ft.txt echo username'
>>c:\temp\ft.txt echo password'
>>c:\temp\ft.txt echo cd notindexed'
>>c:\temp\ft.txt echo put date.zip'
>>c:\temp\ft.txt echo bye'
print @bigscript
exec master..xp_cmdshell @bigscript
</code>
But both options only create my text file with the first line (uesrname).
This is a small example of a larger portion of my project so I hope there is a way to do this.
Thanks!
I am trying to use xm_cmdshell to create and populate a .txt file with the following data:
username
password
cd notindexed
put date.zip
bye
I can add multiple rows to my text file with the following:
<code>
exec master..xp_cmdshell '>c:\temp\ft.txt echo username'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo password'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo cd notindexed'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo put date.zip'
exec master..xp_cmdshell '>>c:\temp\ft.txt echo bye'
</code>
However, is there a way I ran run it as one single script? I tried:
<code>
exec master..xp_cmdshell '>c:\temp\ft.txt echo username'
>>c:\temp\ft.txt echo password
>>c:\temp\ft.txt echo cd notindexed
>>c:\temp\ft.txt echo put date.zip
>>c:\temp\ft.txt echo bye'
</code>
and
<code>
declare @bigscript varchar(500)
set @bigscript =
'>c:\temp\ft.txt echo username'
>>c:\temp\ft.txt echo password'
>>c:\temp\ft.txt echo cd notindexed'
>>c:\temp\ft.txt echo put date.zip'
>>c:\temp\ft.txt echo bye'
print @bigscript
exec master..xp_cmdshell @bigscript
</code>
But both options only create my text file with the first line (uesrname).
This is a small example of a larger portion of my project so I hope there is a way to do this.
Thanks!