I need to write an console application that returns a return code that can be captured through xp_cmdshell.
I started with c# code as follows,
class Program
{
static int Main(string[] args)
{
//make sure the correct number of arguments are being passed.
if (args.Length !=5)
{
Console.WriteLine("not thr right number of args. \nUsage SFTPUploadFile <host> <port> <username> <password> <localFilePath>");
return 1;
}
return 0;
}
}
The XP_cmdhsell I am using some code I found
declare @rc int
create table #output (id int identity(1,1), output nvarchar(255) null)
insert #output (output) exec @rc = master..xp_cmdshell 'd:\FILENAME PARA1 PARA2 PARA3 PARA4 PARA5'
select * from #output where output is not null order by id
drop table #output
but when I run my xp_cmdshell, I just get null. Shouldn't I be getting 1 or 0?
Thanks