How to execute operation system commands by using TSQL without enabling xp_cmdshell.

Hi Experts
Looking for advise if one can use operation system commands using TSQL without enabling xp_cmdshell. 
actually using xp_cmdshell requires sysadmin privs which I am unable to provide (directly or using proc) to a user  but the user needs some operating system commands to execute for file manipulation from sql server session. Please share your thought.
Best Regards 
khalil

>but the user needs some operating system commands to execute for file manipulation from sql server session
See article here
http://www.mssqltips.com/sqlservertip/2014/replace-xpcmdshell-command-line-use-with-sql-server-agent/:
"Problem
I need to run something from the command-line, but based on best practices xp_cmdshell has been disabled. The task that needs to run is an internal process that will originate from within SQL Server. Is there a way to do this without using xp_cmdshell?
Solution
The use of xp_cmdshell is generally frowned upon and is now recommended to be disabled, unless it is absolutely necessary.  There is a solution that works around this restriction via the use of SQL Server Agent.
Wherever SQL Server is installed, SQL Server Agent is installed with it (except for SQL Express). SQL Server Agent has the ability to run job steps which invoke the command shell. And in the case that the job is owned by a member of the sysadmin fixed server
role, the job will execute as the service account under which the SQL Server Agent is running. "
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

Similar Messages

  • How to execute Operating System commands from Stored procedure.

    Any help on how to execute Operating System commands from stored procedures will be appreciated.
    Nanditha.

    Search the forums for 'External Procedure' and you will find example code that has been posted before.

  • How to: execute operating system commands from PL/SQL

    System: IBM pSeries AIX
    Oracle: 11g Enterprise
    Is there a quick way to execute operating system commands from PL/SQL?
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.

    Is there a quick way to execute operating system commands from PL/SQL?
    NO
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    WHY ON EARTH, such action will create a new connection and become a resource hog?
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Which is perfect for the purpose.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.
    NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
    Sybrand Bakker
    Senior Oracle DBA

  • Executing operating system command within trigger or procedure

    Hello
    Can some one help me out as how to execute operating system command (unix or windows ex.. stop,start,cc,del or copy etc...) in a trigger or procedure.
    My requirement is, if some predefined error occure then listener listener should be stopped automatically.
    Thanks in advance
    kvss

    Here is some code to tell you how to do:
    First a small Java program that taker a string as a parameter and executes it as an os-command
    import java.lang.Runtime;
    import java.lang.Process;
    public class Commands extends Object {
    * Constructor
    public Commands() {
    // On NT the command should be like this "cmd /c del c:\temp\readme.txt"
    // exec execute('cmd /c del c:\temp\readme.txt');
    public static void execute (String cmd ) {
    try {
    Process p = Runtime.getRuntime().exec(cmd);
    try {
    p.waitFor();
    catch (java.lang.InterruptedException intex ) {
    intex.printStackTrace();
    System.out.println("Return = "+ p.exitValue());
    System.out.println(" Done ...");
    catch ( java.io.IOException iox) {
    iox.printStackTrace();
    ===================end of java ====
    Use loadjava to load it into the database and create a pl/sql wrapper around the java code.
    See the manual about loadjava details.
    Log in to sqlplus as SYSTEM and create a role for this purpose e.g. 'JAVA_ROLE'
    and exec the following as SYSTEM or SYS to make sure the user has the the needed privs.
    dbms_java.grant_permission('JAVA_ROLE','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete');
    dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','writeFileDescriptor',null);
    dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','readFileDescriptor',null);
    and you're done.

  • Vista: use the windows program manager to execute operating system commands

    attempting to run forms 6 on vista... the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.
    in windows vista i get a message box indicating "use the windows program manager to execute operating system commands".
    is this windwos vista message? would this have to do with permissions?
    any insight most appreciated and thanks in advance.

    I don't know about the HOST-problem, but..
    the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.What about putting the logic from the SQL*Plus-scripts into a database-procedure and call that instead. I think,, with the current approach you will get problems at least when you have to migrate to Web (e.g. Forms 10g).

  • How to use Operating System Commands while using define in sqlplus

    How to use Operating System Commands while using define in sqlplus . The Host OS is Linux
    define report_name=PROD_${host date "+%b"}.html
    The above is not working.
    The output should be 
    define report_name=PROD_JAN.html
    Regards,
    DB

    of course I was talking nonsense: the problem here is the mixing of bind variables and DEFINE variables.
    With the following changes the script should work (the conditions for begin_interval_time are perhaps not what you want):
    variable snap1 number
    variable snap2 number
    variable rptname varchar2(20)
    begin
    SELECT min(snap_id) into :snap1 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
    SELECT max(snap_id) into :snap2 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
    end;
    col file_name_value new_value report_name noprint
    select 'PROD_'|| to_char(sysdate,'MON') || '_' ||  to_char(sysdate,'DD') file_name_value  from dual;
    define  report_type  = 'html'
    define num_days=2
    define begin_snap=:snap1
    define end_snap=:snap2
    @@?/rdbms/admin/awrrpt.sql

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • How to execute a system command with call executable in teststand 4.2.1?

    Hi All,
          how to execute a system command with "call executable" step in teststand 4.2.1?
          example as i want to quit a application.using "taskkill /f /im xxx.exe".And execute other system command(DOS).
    BR
    Johnny

    Hi, 
    I want to run netstat -an | find "8080" command from command prompt using call executable in test stand. after that i would like take the std output to local variable. 
    Attachments:
    callsettings.jpg ‏404 KB

  • How to Run Operating System Command Before/After Message Processing SAP PI

    Hi,
    We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".
    When we use single command say for example cp or mv (copy or move) the commands get executed fine.
    eg: cp %F /var/opt/data/outbound/Test/Dummy.txt 
    /this works fine/
    when we club commands together or try to redirect the outputs of commands, none of the commands get executed.
    eg:
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    or
    wc -l %F > /var/opt/data/outbound/Test/Dummy.txt
    Is it possible to execute multiple commands or redirect the output  of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.

    Hi Harleen,
    try like this
    cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
    instead of semicolon try this
    (1) &
    command1 & command2
    Execute Command1 and then execute Command2
    (2) &&
    command1 && command2
    Runs the command2 only when command1 doesn't Complete successfully
    (3) ||
    command1 || command2
    Runs the second command if the first command had an error
    (4) ()
    (command1 || command2) || (command3 & command4)
    Defines the order in which commands are to be executed
    Regards
    Suraj

  • Executing Operating system commands in ABAP

    Hi
    I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
    Thank You.
    Eswar

    Hi,
    you can try something like this.
    data:cmd(254) type c.
    data: RESULT(255) OCCURS 100 WITH HEADER LINE.
                cmd = 'ls'.
    ** Execute command
      REFRESH RESULT.
      CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
                    ID 'TAB'     FIELD RESULT-*SYS*.
    Kostas

  • Executing Operating system command

    I have a file(ftp)-xi-file(ftp) scenario. I want to run a operating system command on output/processed file which is on a different physical server through a script. But I have seen my script is not working. But when I did the same on the same physical server on which XI is hosted it is working fine. Could you plz somebody advise whether it works ?? if it is the case what precaustions should we take ??
    thanks
    kumar

    Hi Palnati
    OS command will run on XI OS only so you need to use FTP parameter in the script and "permanent connection" as connection mode
    Check this thread also
    Re: FTP ReceiverChannel and OS commands help
    Thanks
    Gaurav

  • How to execute a system command on a remote UNIX server?

    I would like to execute a system command (for example "df") on a remote UNIX machine.
    A simple example would be welcome...
    Thanks

    I would like to execute a system command (for example
    "df") on a remote UNIX machine.
    A simple example would be welcome...None will be forthcoming.
    Executing a process is relatively simple. However doing this on a remot system is another matter.
    See http://sourceforge.net/projects/sshtools/
    and/or http://javassh.org/space/start
    Other resources to be found with Google.

  • How to install operating system on new hard drive without installation disc on macbook pro 2011

    My macbook pro 2011 does not come with a recovery disc or any disc at all, my hard drive recently failed and i have no backup. i have replaced the hard drive but don't know how to install the operating system on the new hard drive.

    If it originally shipped with 10.7 or newer, connect the computer to the Internet and start it up with the Option, Command, and R keys held down. You'll be able to install an OS.
    If it shipped with 10.6.8 or earlier and wasn't upgraded to use Apple's Internet Recovery system, phone AppleCare and order the disks.
    (109822)

  • Executing Operating system commands

    Hi,
    I need to execute sql*loader from APEX(sqlldr scott/tiger CONTROL=ulcas1.ctl ). How can I implement this in APEX. In oracle forms , I can execute this by a trigger when-button-pressed in a push button - host('sqlldr scott/tiger CONTROL=ulcas1.ctl ').
    Regards
    JIJU

    I took the mention of the Forms method to indicate that the requirement was another manifestation of that currently popular meme Calling calc.exe from APEX
    (At least I've thought there was a lot of it about at the moment...)
    @Jiju - there is no equivalent of host in ApEx. You can write your application to allow files to be uploaded to the server and parsed by your application, or written to the server file system and read as an external table. There are a lot of threads about this kind of thing in this forum: search for "file upload"...

  • PL/SQL: how to execute host-/system command without ext. procedure call

    Hello,
    I would like to execute a systemcall out of a PL/SQL-package (e.g. execute a shell script). Seems like that this is just possible with a external procedure call.
    Are there any other solutions available?
    Rgds
    JH

    With 10g you can use DBMS_SCHEDULER: see Re: Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch fi

Maybe you are looking for