-
xp_cmdshell
Hi there!
Is it possible to supply variable for the xp_cmdshell parameter?
here's an example:
declare @@okay char(20)
select @@okay = "dir c:mssqlinn"
exec master..xp_cmdshell @@okay
but this doesn't work. is there any workaround on this? instead
of writing a new extended sp to cater for this.
thanks in advance.
dion
-
xp_cmdshell (reply)
On 11/2/98 1:42:05 PM, bads wrote:
> Hi there!
Is it possible to supply variable for the xp_cmdshell
> parameter?
here's an example:
declare @@okay char(20)
select
> @@okay = "dir c:mssqlinn"
exec master..xp_cmdshell
> @@okay
but this doesn't work. is there any workaround on this?
> instead
of writing a new extended sp to cater for this.
thanks in advance.
dion
--
dion, I think the problem is in your variable declaration, use
declare @okay char(20)
select @okay = "dir c:mssqlinn"
exec master..xp_cmdshell @okay
also look at the extended stored procedures for this type of function (dir), they're not documented so they won't necessarily be present in future releases but they come in handy.
cheers..
Mike
-
xp_cmdshell (reply)
On 11/2/98 5:07:39 PM, Mike Doyle wrote:
> On 11/2/98 1:42:05 PM, bads wrote:
> Hi there!
Is it possible to supply
> variable for the xp_cmdshell
> parameter?
here's an
> example:
declare @@okay char(20)
select
> @@okay = "dir
> c:mssqlinn"
exec master..xp_cmdshell
> @@okay
but this
> doesn't work. is there any workaround on this?
> instead
of writing
> a new extended sp to cater for this.
thanks in
> advance.
dion
--
dion, I think the problem is in your variable
> declaration, use
declare @okay char(20)
select @okay = "dir
> c:mssqlinn"
exec master..xp_cmdshell @okay
also look at the
> extended stored procedures for this type of function (dir), they're not
> documented so they won't necessarily be present in future releases but
> they come in handy.
cheers..
Mike
tried that one before and doesnt work. i tried all the possible kind
of declaration and still not working. it's just an example of one i did.
where can i find undocumented ex stored proc?
thanks.
-
xp_cmdshell (reply)
On 11/3/98 12:09:16 PM, dion wrote:
> On 11/2/98 5:07:39 PM, Mike Doyle wrote:
> On 11/2/98 1:42:05 PM, bads
> wrote:
> Hi there!
Is it possible to supply
> variable for the
> xp_cmdshell
> parameter?
here's an
> example:
declare @@okay
> char(20)
select
> @@okay = "dir
> c:mssqlinn"
exec
> master..xp_cmdshell
> @@okay
but this
> doesn't work. is there
> any workaround on this?
> instead
of writing
> a new extended sp to
> cater for this.
thanks in
> advance.
dion
--
dion, I think the
> problem is in your variable
> declaration, use
declare @okay
> char(20)
select @okay = "dir
> c:mssqlinn"
exec
> master..xp_cmdshell @okay
also look at the
> extended stored
> procedures for this type of function (dir), they're not
> documented
> so they won't necessarily be present in future releases but
> they
> come in handy.
cheers..
Mike
tried that one before and doesnt work.
> i tried all the possible kind
of declaration and still not working.
> it's just an example of one i did.
where can i find undocumented ex
> stored proc?
thanks.
Dion,
unsure as to why your code is not working, what error are you getting ? What if you put a begin and end at start and end of your code, i.e.
begin
<code>
end
undocumented ex. stored procs can be found in the master database, try..
select * from master..sysobjects where name like "xp_%"
which should give you a list of the procedures.
let me know the error message you are getting, if any ?
cheers..
Mike
-
xp_cmdshell (reply)
On 11/3/98 5:40:09 PM, Mike Doyle wrote:
> On 11/3/98 12:09:16 PM, dion wrote:
> On 11/2/98 5:07:39 PM, Mike Doyle
> wrote:
> On 11/2/98 1:42:05 PM, bads
> wrote:
> Hi there!
Is it
> possible to supply
> variable for the
> xp_cmdshell
>
> parameter?
here's an
> example:
declare @@okay
>
> char(20)
select
> @@okay = "dir
> c:mssqlinn"
exec
>
> master..xp_cmdshell
> @@okay
but this
> doesn't work. is there
>
> any workaround on this?
> instead
of writing
> a new extended sp
> to
> cater for this.
thanks in
> advance.
dion
--
dion, I
> think the
> problem is in your variable
> declaration, use
declare
> @okay
> char(20)
select @okay = "dir
> c:mssqlinn"
exec
>
> master..xp_cmdshell @okay
also look at the
> extended stored
>
> procedures for this type of function (dir), they're not
> documented
>
> so they won't necessarily be present in future releases but
>
> they
> come in handy.
cheers..
Mike
tried that one before and
> doesnt work.
> i tried all the possible kind
of declaration and still
> not working.
> it's just an example of one i did.
where can i find
> undocumented ex
> stored proc?
thanks.
Dion,
unsure as to why
> your code is not working, what error are you getting ? What if you put a
> begin and end at start and end of your code,
> i.e.
begin
end
undocumented ex. stored procs can be found in
> the master database, try..
select * from master..sysobjects where name
> like "xp_%"
which should give you a list of the
> procedures.
let me know the error message you are getting, if any ?
cheers..
Mike
++++++++++++++++++++++++++++
Mike,
here's error message :
(1 row(s) affected)
Error executing extended stored procedure: Invalid Parameter Type
to give you an idea of what i am trying to accomplish ,
my code will select all the name in sysdevices and
compared it in the device directory in NT. And then all the
files not in sysdevices will be deleted. this is one of the things
i want to accomplish.
thnks again.
-
xp_cmdshell (reply)
Here's a code example to use to help you get started with this, if you're still working on it. It gives a dir listing. Pretty simple, but it should help.
declare @cmd varchar(150)
select @cmd = 'exec master..xp_cmdshell ' + char(39) +
'dir' + char(39)
exec (@cmd)
-
xp_cmdshell (reply)
On 11/4/98 12:33:34 PM, dion wrote:
> On 11/3/98 5:40:09 PM, Mike Doyle wrote:
> On 11/3/98 12:09:16 PM, dion
> wrote:
> On 11/2/98 5:07:39 PM, Mike Doyle
> wrote:
> On 11/2/98
> 1:42:05 PM, bads
> wrote:
> Hi there!
Is it
> possible to supply
>
> variable for the
> xp_cmdshell
>
> parameter?
here's an
>
> example:
declare @@okay
>
> char(20)
select
> @@okay = "dir
>
> c:mssqlinn"
exec
>
> master..xp_cmdshell
> @@okay
but
> this
> doesn't work. is there
>
> any workaround on this?
>
> instead
of writing
> a new extended sp
> to
> cater for
> this.
thanks in
> advance.
dion
--
dion, I
> think the
>
> problem is in your variable
> declaration, use
declare
> @okay
>
> char(20)
select @okay = "dir
> c:mssqlinn"
exec
>
>
> master..xp_cmdshell @okay
also look at the
> extended stored
>
>
> procedures for this type of function (dir), they're not
> documented
>
>
> so they won't necessarily be present in future releases but
>
>
> they
> come in handy.
cheers..
Mike
tried that one before and
>
> doesnt work.
> i tried all the possible kind
of declaration and
> still
> not working.
> it's just an example of one i did.
where
> can i find
> undocumented ex
> stored
> proc?
thanks.
Dion,
unsure as to why
> your code is not working,
> what error are you getting ? What if you put a
> begin and end at start
> and end of your code,
> i.e.
begin
end
undocumented ex. stored
> procs can be found in
> the master database, try..
select * from
> master..sysobjects where name
> like "xp_%"
which should give
> you a list of the
> procedures.
let me know the error message you are
> getting, if any
> ?
cheers..
Mike
++++++++++++++++++++++++++++
Mike,
here's
> error message :
(1 row(s) affected)
Error executing extended stored
> procedure: Invalid Parameter Type
to give you an idea of what i am
> trying to accomplish ,
my code will select all the name in sysdevices and
>
compared it in the device directory in NT. And then all the
files not in
> sysdevices will be deleted. this is one of the things
i want to
> accomplish.
thnks again.
************************************************** ******
-- The following Script works with SQL 6.5
-- The important thing is to use VARCHAR instead of char
DECLARE @cmd varchar(255)
SELECT @cmd = 'dir c:mssqlinn'
CREATE TABLE #temp ( filename varchar(255) NULL )
INSERT #temp EXEC master..xp_cmdshell @cmd
--work with the data
SELECT * FROM #temp
DROP TABLE #temp
GO
Juergen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|