can't use environment variables in command for cmdexec job steps (sql server 7.0)

can't use environment variables in command for cmdexec job steps (sql server 7.0)

Post by Tina Scot » Fri, 05 Feb 1999 04:00:00



I have a job set up with a cmdexec step.  The command has an environment
variable in it.  When the step runs it fails because it doesn't resolve the
environment variable.  This is on a Windows NT Workstation 4.0 sp4.  If I
replace the environment variable with the hardcoded value, it works.  My
command is something like this...

c:\rexx\regina %DBASCRIPT%\db_maint.rexx parm1 parm2 and so on.

I can run the command from a DOS prompt and the environment variable is
resolved.  Any suggestions?


 
 
 

can't use environment variables in command for cmdexec job steps (sql server 7.0)

Post by Tibor Karasz » Fri, 05 Feb 1999 04:00:00


Tina,

I haven't really worked with environment variables, but note that it would
have to be a system environment variable (or one that exists for the account
that SQLExecutive/SQLServerAgent is using).

--
Tibor Karaszi
MCSE, MCSD, MCT, SQL Server MVP
Cornerstone Sweden AB
Please do not respond by e-mail unless explicitly asked for.


>I have a job set up with a cmdexec step.  The command has an environment
>variable in it.  When the step runs it fails because it doesn't resolve the
>environment variable.  This is on a Windows NT Workstation 4.0 sp4.  If I
>replace the environment variable with the hardcoded value, it works.  My
>command is something like this...

>c:\rexx\regina %DBASCRIPT%\db_maint.rexx parm1 parm2 and so on.

>I can run the command from a DOS prompt and the environment variable is
>resolved.  Any suggestions?




 
 
 

can't use environment variables in command for cmdexec job steps (sql server 7.0)

Post by Buddy Ackerma » Fri, 05 Feb 1999 04:00:00


Maybe if you change the cmdexec to a TSQL and executed the command using
xp_cmdshell.  I test the following command and it worked fine.

    exec master..xp_cmdshell 'dir %systemroot%'

--Buddy


>Tina,

>I haven't really worked with environment variables, but note that it would
>have to be a system environment variable (or one that exists for the
account
>that SQLExecutive/SQLServerAgent is using).

>--
>Tibor Karaszi
>MCSE, MCSD, MCT, SQL Server MVP
>Cornerstone Sweden AB
>Please do not respond by e-mail unless explicitly asked for.


>>I have a job set up with a cmdexec step.  The command has an environment
>>variable in it.  When the step runs it fails because it doesn't resolve
the
>>environment variable.  This is on a Windows NT Workstation 4.0 sp4.  If I
>>replace the environment variable with the hardcoded value, it works.  My
>>command is something like this...

>>c:\rexx\regina %DBASCRIPT%\db_maint.rexx parm1 parm2 and so on.

>>I can run the command from a DOS prompt and the environment variable is
>>resolved.  Any suggestions?



 
 
 

can't use environment variables in command for cmdexec job steps (sql server 7.0)

Post by Roy Harv » Fri, 05 Feb 1999 04:00:00


Tina,

As a test, run a simple SET command the same way you are running the
command with the problem.  The results returned should show you all
the environment variables that are available.  I believe you will not
find your variable there because your command is not running in the
same environment context as the DOS prompt where you tested it.

Roy

 
 
 

1. SQL Server Agent CmdExec job step fails with Permission Denied

We have a very security conscious client who makes it a
practice to remove the system account (local admin
account?) from his servers.  SQL Server and Server Agent
then run under a domain account.  

SQL Server Agent is used to run a job one of whose steps
calls an ActiveX exe which in turns fires up another
ActiveX exe, which in turn creates files using VB's "Open
for Append" or "Open for Output" syntax.  This CmdExec
step fails with the exe reporting "Permission Denied".  
However, when the exe is run from the command line it
succeeds, even when one is logged in as the same domain
user used by SQL Server and SQL Server Agent.  

I've found a number of references to privilege problems
related to DTS and SQL Server Agent CmdExec job steps, but
I have not found anything that seems to address my
specific problem.  

Any help appreciated.

2. A question about exporting

3. Run DTS with Agent CMDExec using Environment Variables

4. pgsql/src/include parser/parse_coerce.h catalo ...

5. SQL Server agent CMDEXEC job does not take command line parameters

6. Create View problem

7. SQL Agent CmdExec job steps

8. COMMET COURSE ON ACTIVE DATABASES - ATHENS, GREECE Jun. 29- July 1

9. sql 7.0 error 213, insert error, sql server agent, editting job step

10. multiple commands in a CmdExec step

11. Run commands in a CmdExec step with sql7.0 on win2000

12. Step CmdExec in Job

13. CmdExec/ Xcopy command Failure (SQL 7.0)