How to use su in a Korn shell script???

I'm developing a script which needs to log in to a second user id to complete its processing. When I use su, it prompts for a password. I enter the password and then it hangs at the system prompt. If I enter 'exit', it returns to the original user id and continues the script from there. How can I make it continue executing the script in the second user id?
The system that I'm using doesn't have the 'expect' command, so I have to find another way.

This cannot be done by standard Unix commands. But
this is possible by
1. Expect
2. Sudo with NOPASSWD option.
3. SSH by private/public authentication.
Among this SSH is very safe, but sudo is easy to configure and use. Try sudo.
- Hemant Rumde

Similar Messages

  • How to use the result of simple shell script?

    The shell script below retrieves the length of an audio file:
    set aFile to choose file
    do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration"
    I'm wondering, how can I copy the result to the clipboard or set the value of a variable to it?
    Total newbie question. I have no idea about shell scripts - I just found the script above online.
    Thank you so much!

    Here:
    set the clipboard to (do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration")
    or:
    set A to do shell script "afinfo " & quoted form of (POSIX path of aFile) & "|grep duration"
    (53997)

  • Looking for input on korn shell scripts to java programs

    I have a situation where there are several korn shell scripts and some manual processes using ms access to manipulate input files that will be used to pass to an applications command level commands for the purposes of updating the applications database. That being said, I am looking at creating the same as mentioned above in Java instead of ksh scripts. Mainly for the following reasons.
    The vendor is going web based, using a Java enabled web server, so these korn shell scripts if converted to Java could be called from the web jsp pages, etc.
    The other purpose is I see Java as a better tool for parsing the flat files and calling sql commands from the parsed data.
    I admit I am more a Java programmer than a korn shell programmer.
    What thoughts does this group have to using Java or should I polish my korn shell off a bit more?
    Thanks in advance
    Dean-O

    Hi,
    Is possible run Unix script under java application?, how?
    thanks

  • Korn shell script

    Hi,
    I have created korn shell script whoch takes records and spool into file as every column is ~ seperated. At the last I have to show total count as this one
    '[EOF <<count>>]' It is displaying but '[EOF' at one line and then ACTUAL COUNT value at next line.code is like this
    cnt variable in this I already take as count from query. Can anybody helps me?
    CREATEOUTPUT=`sqlplus -s $DATABASE@$ORACLE_SID <<SQLSCRIPT
         set heading off;
            set feedback off;
         set echo on;
         set verify off;
         set linesize 150;
         set pagesize 0;
         spool $filename
         /* 1.0 version developer needs to be change this with every relase*/
            SELECT '$BILL_SYSTEM'||' '||to_char(gnvgen.systemdate,'DD/MM/YYYY HH:MI:SS')||' '||'1.0' from dual;
         SELECT b.account_num ||'~'||
                        FROM pvaccount12 b,pvcustomer7 c,PROVIDER d,pvcustomertype2 e,pvbillsummary13 f
         WHERE b.customer_ref=c.customer_ref
         AND c.PROVIDER_ID= d.PROVIDER_ID  
         AND c.customer_type_id = e.CUSTOMER_TYPE_ID
         AND f.account_num =  b.account_num
         AND F.OUTSTANDING_DEBT_MNY <>0
         AND b.invoicing_co_id=3
         AND trunc(f.bill_dtm) <= trunc(gnvgen.systemdate)
         ORDER BY b.account_num;
         SELECT '[EOF'||'$cnt'||']' FROM dual;
         spool off;
         exit
         SQLSCRIPT
         `

    How did you set cnt variable ?

  • How we can call or execute a SHELL script through Oracle forms or Reports

    How we can call or execute a SHELL script through Oracle forms or Reports.Its urgent.......

    Use HOST command.

  • Procedure call from SQL*Plus in Korn Shell Script

    I am trying to excute a procedure from sqlplus, truncate_audit_table. I doesn't execute. If I do it manually
    it executes. I have tried multiple ways, as below. This is inside a Korn Shell scripts that creates the procedure
    and counts the aud$ table. All that works, but does not truncate the aud$ table. It does not do it, no error, just
    passes it by. Does anybody know why?
    ${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
    set feedback on
    @/backup/oracle/orcl/audit/truncate_audit_table.sql
    select count(*) from sys.aud$;
    exec truncate_audit_table;
    exit
    EOF
    ${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
    set feedback on
    @/backup/oracle/orcl/audit/truncate_audit_table.sql
    select count(*) from sys.aud$;
    begin
         truncate_audit_table;
    end;     
    exit
    EOF
    This is the procedure that is being called:
    create or replace procedure truncate_audit_table
    as
    begin
    execute immediate 'truncate table sys.aud$';
    end;
    /

    aud$ is owned by sys. You can see it does the count with or without the "\".
    It creates the procedure under SYS , but does not execute it.
    Truncate aud$ table...
    Procedure created.
    COUNT(*)
    422
    1 row selected.
    ===============================================================
    audit_maintenance.ksh Completed: Thu Oct 26 14:03:17 GMT 2006
    ===============================================================

  • Oracle 10g and Korn Shell Scripting

    I have a table,SALES_STAGING, with 3 main columns.
    Sales_Date, Sales_type,Sales_Code.
    A sale is added to the table then waits until approved to be processed. The Sales_Code is 1(waiting approval). Then manually changed to 2 every 30 minutes by sales staff except on weekends. By Monday,a large queue develops. This must be changed because the queue is slowing the system. Can someone help create a Unix Korn shell script to
    1) Run every 30 minutes via Crontab
    2)login to the Oracle DB.
    3)Count the number of records to be processed, if any.
    4)Update another 'log' table with the time it ran and the records to be processed
    5)if there are less than 20 add another 50 to be processed by changing the Sales_Code from 1 to 2.
    This would really help out tremendously! Thank you.

    Wait... Isn't this forum designed for the sharing of information? The experts here shouldn't be concerned whether the request is from a Student, Oracle newbie or Developer and should focus on the request. If you are capable of assisting then I am hoping you will out of the core respect for professionalism and the motivation to provide something of value to others. If not, don't waste my time or any one else by responding with preconceived judgments and insulting remarks as these will be reported.
    Sales transactions can peak at 20,000 per hour with an average of several million thru the week. Those sales by VIP customers are immediately identified and have a priority for approvals because their balances can easily exceed $1,000,000.00. There is a pre-approval process to be introduced but until programs can be modified/tested and deployed we need a quick fix. The programming system isn't slow, it's the limited human resources approving VIP customers. My request was to keep it simple and expand on it myself to include the entire scope of our project. dbms_scheduler, although a good idea will require DBA assistance and there is no resource available. I need a simple working model to give me some direction/ideas...

  • How to use dbms_pipe to execute a shell program

    Hi ,
    I have a stored procedure....with an if else condition in it
    what i want is
    if condition is true... then
    execute the shell script
    else
    do nothing
    how do i achieve this ? how do i execute a shell script from with in stored proc .. i heard dbms_pipe can be help ful ..could any one throw more light or an example to achieve this?

    learning_man wrote:
    sure i have gone through that option... but the thing is that.....i wnat to run the shell script only if a certain condition inside the stored proc passed some thing like
    if condition = true then
      dbms_scheduler.create_job(
      job_name   => 'TESTSH',
      job_type   => 'EXECUTABLE',
      job_action => '/mydir/myscript.sh',
      start_date => SYSTIMESTAMP,
      enabled    => TRUE,
      comments   => 'testsh');
    else
    dont do anything...
    end if;
    where as scheduler is used to schedule .... the time... i dont want to schedule the time.... i want to run the shell script based on some condition becoming true inside the procAbove code snippet does exactly what you're talking about.
    Max
    http://oracleitalia.wordpress.com

  • SAP and Korn shell scripts

    Hi,
    It looks SAP default is c-shell only.  I have an issue, when remote calls (rsh) to OS to run a command, k-shell script does not source the .profile.  Do any one face this issue? how it was resolved.
    Thanks, R

    Hi,
    It is a very, very long time, but as far as I remember that is an issue with the rsh.
    I think the solution is not to use the Ksh on the destination.
    I think there is/was a note indicating so.
    For that reason SAP does recommend to use only the cshell.
    Edited by: Fidel Vales on Nov 14, 2009 11:02 AM
    hi again.
    Check note 202227.
    > In general, you can use the Korn shell (ksh) as a login shell, however, note that the implementation of the Korn shell differs among the different UNIX platforms. This has lead to problems within SAP, in particular this is the case when you start external programs from an SAP system.
    and note 188772
    > The .profile file is not read under ksh.

  • Error Using dbms_scheduler to call a shell script

    Hi,
    I have been assigned a job of sending emails through unix utility(Mailx), based on certain activity in database.
    Email needs to be sent on insert/update of a column in one of the database tables.
    I am trying to use the block below to call the unix script responsible to send mails:
    begin
    dbms_scheduler.create_job
    job_name => 'TPP_SEND_EMAIL_JOB',
    job_type => 'EXECUTABLE',
    job_action => '/opt/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
    repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
    enabled => true,
    comments => 'Send Email on ISU update'
    end;
    sndmailscrpt.ksh: Script to send email is embedded within the shell script
    I am getting the below error when i try to run the job using 'exec dbms_scheduler.run_job('TPP_SEND_EMAIL_JOB');'
    Error:
    ORA-27370: job slave failed to launch a job of type EXECUTABLE
    ORA-27300: OS system dependent operation:accessing extjob wrapper failed with status: 2
    ORA-27301: OS failure message: No such file or directory
    ORA-27302: failure occurred at: sjsec 3
    ORA-06512: at "SYS.DBMS_ISCHED", line 150
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
    ORA-06512: at line 1
    I am not aware of any db related permissions that needs to be given, is this related to that or is there somethin i need to do for execution to be successfull
    Request you to let me know the exact solution and also the steps i need to take in order to ensure successfull execution of this script.
    Please also let me know if there is any other way wherein i can call a unix script from a database trigger on run time(i.e, whenever insert/update on a particular column in database)
    Regards,
    Hemanth

    Hi All,
    Thank you for your inputs.
    I am now pressed to explore the option of utl_mail as this dircetly sends mail from database. This is suggested as an option for my delivery now.
    I am able to install utl_mail and send a mail using the block below:
    begin
    utl_mail.send(
    sender => '[email protected]',
    recipients => '[email protected]',
    subject => 'Testing utl_mail',
    message => 'The receipt of this email is checking on working of UTL_MAIL '
    exception
    when others then
    dbms_output.put_line('error: '||sqlerrm);
    end;
    The block gets executed successfully, but i have not received a mail yet, is there a table or oracle log from where i can trace the delivery status for the mai, or if the mail is successfully sent too?
    I have heard from users in this forum for support of mime type "HTML", Should i pass the whole html body in the *'message'* input parameter here or can i pass a html template name with path present else where?
    Please do assist me in this regard.
    Regards,
    Hemanth

  • How to use msword as editor in sap script and smart form..

    how to use msword as text editor in sap scripts and smartforms..

    Hi
    Go through the link given below :
    Saptechnical. com
    tutorials
    smartforms
    you will find solution for how to use MS word as editior.
    Or
    Call transaction I18N
    go to I18N Customizing -> MS Word as Editor.Choose the Help-Button and follow the instructions.
    If transaction I18N is not available in your system yet (see SAP Note 848036), you can also enable this feature via program RSCPINST.
    Call transaction SE38, enter program RSCPINST and press F8. On the next screen,select Goto -> Set MS Word as Editor.
    With Regard
    Nikunj shah

  • Using launchctl command within a shell script

    I have successfully installed two daemons, and I would like to be able to disable and enable them via shell scripts, called by the daemons themselves. Here is my first shell script:
    #!/bin/sh
    # Testing for presence of a CODEBOY file
    if [ -e "/Volumes/CODEBOY/Change.txt" ]
    then
    osascript '/Users/praxisii/Library/Scripts/MacScript.scpt'
    launchctl unload -w '/Users/praxisii/Library/LaunchDaemons/WaitDaemon.plist'
    launchctl load -w '/Users/praxisii/Library/LaunchDaemons/RunDaemon.plist'
    fi
    The daemon works just fine, running the background, calling this script, which is waiting for me to plug in my flash drive (entitled CODEBOY). When the flash is plugged in, the applescript is called, and the first launchctl command is executed, which disables the WaitDaemon. As advertised, the .plist file is re-written with the Disabled key set to true. The next line (which is supposed to enable the RunDaemon) is never executed.
    Similarly, if the launchctl line is placed before the osascript line, the applescript is never called. It is as if the shell ignores everything after a single launchctl command, which it will execute.
    Any ideas or comments?

    Gary:
    Thank you for the link to the TN2083. Long, but very informative.
    I appreciate all the other comments on this thread. I am an amateur AppleScript/UNIX scripter, and any opportunity to learn more is much appreciated.
    I have completely re-worked my original launchd agent system for automatic processing of a file on a flash drive. Here is the .plist file that I now use:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>RunOSAscript</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
    <string>/usr/bin/osascript</string>
    <key>ProgramArguments</key>
    <array>
    <string>osascript</string>
    <string>/Users/casdvm/Desktop/AutoFlash.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>ServiceDescription</key>
    <string>Runs Applescript directly</string>
    <key>StandardOutPath</key>
    <string>/Users/casdvm/Desktop/AutoFlashLog.txt</string>
    <key>StartInterval</key>
    <integer>25</integer>
    </dict>
    </plist>
    The AutoFlash.scpt is an Applescript that simply uses the Finder to check for the presence of a specific file on the flash drive. If it is there, and a certain script property has a value of 2, then it runs the AppleScript that processes the desired file on the flash drive. Once that is done, the script property is set to 0 (to prevent the processing from happening over and over again.). Once the flash drive is removed, the script property is set back to 2 in anticipation of the next time the flash drive is plugged in.
    It is much simpler than the two agents I was messing with beforehand. I did indeed discover that this .plist needs to be saved in the LaunchAgents folder of my user Library (thanks again for pointing that out, Gary).
    The only problem that I have involves the continuous calling of the Applescript from the launchd agent. As you can see from my .plist file, that AppleScript is called every 25 seconds. I tried setting it up using the OnDemand key, but I kept receiving a re-spooling error of some sort (I don't recall exactly; my notes are sketchy on that phase of testing), so I just decided to have it go every 25 seconds. It really doesn't matter, since I can leave the flash drive plugged in all day anyway, and it only processes the desired file once.
    Thanks again for all the commentary and discussion; I am grateful for the assistance.
    Craig Smith

  • How to use fscommand or equivilant in action script 3

    Hello every one,
    I am new to action script 3, I want to burn my flash
    projector file on a CD so that when it plays it opens in full
    screen mode with movie size set to 100% and no scaling allowed. I
    use to do it with FScommand in previous versions but it doesn't
    work in flashcs3. Can someone help this poor soul how to use it in
    actionscript3.
    Thanks in advance.

    do a search for fscommand in the Flash CS3 help and look for
    a file heading called AS2.0 Migration Once you find that file, do a
    search for fscommand again inside the document.

  • Regarding how to use the function module *control_form* in scripts

    HI friends,
    Can any one tell why and where do we use the function module control_form in scripts. Can you give me a small scenario how to use in scripts.

    hi satish,
    by using this function module we can pass the control
    commands to FORM THROUGH ABAP/4 PROGRAM.
    see the following example:
    TABLES: kna1.
    DATA: BEGIN OF it_kna1 OCCURS 0,
          kunnr LIKE kna1-kunnr,
          name1 LIKE kna1-name1,
          ort01 LIKE kna1-ort01,
          land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA:records TYPE i,
         window TYPE i value 1.
    select-options:s_kunnr for kna1-kunnr.
    SELECT kunnr name1 ort01 land1 FROM kna1 INTO TABLE it_kna1
    where kunnr in s_kunnr.
    CALL FUNCTION 'OPEN_FORM'
      EXPORTING
        form     = 'ZSCRIPT4'
        language = sy-langu.
    LOOP AT it_kna1.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element  = 'ELE1'
          function = 'SET'
          type     = 'BODY'
          window   = 'MAIN'.
      DESCRIBE TABLE it_kna1 LINES records.
      IF window lt records.
        window = window + 1.
      CALL FUNCTION 'CONTROL_FORM'
       EXPORTING
            command         = 'NEW-WINDOW'
    EXCEPTIONS
      UNOPENED        = 1
    UNSTARTED       = 2
    OTHERS          = 3
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
      RESULT                         =
      RDI_RESULT                     =
    TABLES
      OTFDATA                        =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SEND_ERROR                     = 3
      SPOOL_ERROR                    = 4
      CODEPAGE                       = 5
      OTHERS                         = 6
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    thanks,
    raji

  • How to extract a subsstring in a shell script

    Hi,
    I need to extract a substring from a string in a shell script. Ideally using a regular expression, but a certain position (character n through n+4) would work in this case, too.
    I am fairly familiar with regular expressions, I just don't know the syntax to use in a shell script
    Thanks for any help!
    Ingo

    The equivalent of Bill's command in bash is:
    expr $junk : '..\(...\)'Read the man page for expr, particularly the ':' operator. You can use any "basic" regular expressions, but not "extended" REs.
    You can also use the stripping operators to remove stuff from the front or end of the string, optionally with a "greedy" match. So:
    <pre>p=/usr/local/clamXav/man/man5/clamd.conf.5
    echo ${p#????} # strip first 4 chars
    /local/clamXav/man/man5/clamd.conf.5
    echo ${p%????} # strip last 4 chars
    /usr/local/clamXav/man/man5/clamd.co
    echo ${p##*/} # greedy strip path components (basename)
    clamd.conf.5
    echo ${p%%man*} # Greedy strip from end
    /usr/local/clamXav/</pre>I dare say these all work in zsh too.

Maybe you are looking for

  • Windows doesn't recognize IPod

    whenever I plug the Ipod into the USB, all I get is an "unknown device" and it wants drivers installed. can't find anything on the site here about downloading such, other than downloading Itunes, which I have done 4 times now. most of the advice I've

  • Should my dimension table be this big

    Im in the process of building my first product dimension for a star schema and not sure if im doing this correctly. A brief explanation of our setup We have products (dresses) made by designers for specific collections each of which has a range of co

  • How to view first page of newsletter (Publisher file convert to ?)

    I am using Dreamweaver CS4 on a Mac.  I am trying to post the first page of our newsletter on the page.  See http://indianaeagleforum.org/newsletter.htm  Here it is FrontPage 2002 and the newsletter was done in Publisher 2007.  I am redoing the websi

  • CQL SELECT clause syntax

    Hi all I have a small question regarding the SELECT clause syntax. In my CEP application I'm processing events which hold several properties, mostly primitives, but a few of type java.awt.Point. I can select the Point object itself in the SELECT clau

  • How to set up an E-mail server, ( To recieve and send outside a company network)

    Hie, The scenario is, our company wants to start hosting their own emails and not through an ISP. I somehow managed to install and configure MS Exchange server 2010, we are able to send and receive mails but only when we are connected to our company