Finding path to source executed shell script
Hello,
I have shell script A which executes shell script B. The scripts A and B reside in the same directory.
Following requirements:
Scripts A and B need to be source executed.
The directory where A and B resides should be anywhere.
The present working directory from where A is executed should be anywhere.
The directory of scripts A and B may not be defined in $PATH.
The current shell could be any Bourne or Korn shell, Linux or Unix.
Problem:
Let's assume scripts A and B are installed in "/custom".
The users working directory is /home/oracle and he executes "source /custom/A".
If script A executes "source ./B", the result would be "source /home/oracle/B", which will fail.
Possible Solution:
Since script A is being sourced, $0 will always be the name of the current shell and not the name and path to script A.
I have not found a universal solution to locate the absolute path of a shell script that is being source executed.
So I was wondering about defining a variable in script A. e.g. SCRIPT_HOME=./custom. When script A executes "source $SCRIPT_HOME/B" it will work, but then script A needs to be customized by the user.
I could write a script C that edits script A to search and edit the SCRIPT_HOME variable. For this to work I will have to verify that script C is not source executed, and that script A is in the same directory as C based on $0. This is not a problem..
The question however is whether I need to create script C, or could simply execute script A with -config argument to edit itself and exit. I would prefer the later case and from what I understand, Unix and Linux do not lock files by default and this should be possible.
Any comments or suggestions please?
Thanks!
Edited by: Dude on Apr 5, 2011 3:59 AM
The $_ solution is actually very simple:
$ cat thatsme
mypath=$(dirname $_)
echo "$mypath/B"
$ source /home/oracle/thatsme
/home/oracle/BI do not need the absolute path of script A. The relative path from my current directory will do as well.
But, it does not work with an alias:
$ alias thatsme='source /home/oracle/thatsme'
$ thatsme
./B
Similar Messages
-
Execute Shell Script through Demantra Workflow
Hi All ,
Can we execute shell script from Demantra Workflow ?
If yes where should we place the shell script file and wat should be the commandline command in the step .
We have the Demantra installed on a windows server and the workflow manager is on a linux server .
the batch file on the windows server can be executed through the secure shell from the linux server .
I am trying to achieve the same through thr demantra workflow
Appreciate any input on the same .
Thanks and regards
SuzyHi,
Shell script is not supported till Demantra 7.2.0.2 WF.
I have checked with Oracle team also and reply I got below for your reference:
QUESTION
*=========*
As per your details, shall we conclude like this:
*"only *.bat and *.exe files can be used in workflow. Demantra standard functionality doe*
*s not support shell script in workflow"*
ANSWER
*=======*
Hi ,
The Demantra standard functionality 7.2.0.2 does support shell script in workflow.
Thanks,
Asya
Please review the note#468071.1-Unable to Run EBS Workflows that Call EngineManager.exe in
You will find this note is referring to the Enhancement Request Bug 6644455-- ANALYTICAL ENGINE
NOT AVAILABLE ON UNIX/LINUX
But the enhancement bug exist and I hope it is fixed in Demantra 7.3.
Tks
MJ -
Upgraded ROX filer not executing shell scripts
Hi all,
I run ICEWM+ROX filer as my lite desktop but after a recent upgrade, ROX does not execute shell scripts on mouse click. It appears that filetype detection has changed so that all scripts are shown with the shellscript icon, whereas before those without a .sh extension where shown with the kde type "cogwheel".
Any tips much appreciated.
My thanks in advance!I've found a lot of things I don't like about the latest ROX upgrade... too much caching nowadays in my opinion.
-
Need Help on Executing Shell Scripts through PL-SLQ
Hi All,
I am trying to execute a shell script from PL-SQL but I am not getting it right .
the code i used is as follows
----JAVA CLASS ---
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
if (isWindows()) {
finalCommand = new String[4];
// Use the appropriate path for your windows version.
finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
//finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
else {
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
new Thread(new Runnable(){
public void run() {
BufferedReader br_in = null;
try {
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
br_in.close();
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
finally {
try {
br_in.close();
} catch (Exception ex) {}
}).start();
new Thread(new Runnable(){
public void run() {
BufferedReader br_err = null;
try {
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
br_err.close();
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
finally {
try {
br_err.close();
} catch (Exception ex) {}
}).start();
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
--- THE PERMISSIONS ---
call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
--- THE SHELL SCRIPT IS -----
#!/bin/sh
# This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
# and the sends the single line stream to the new file with the use of 'gawk' command
# so finaly the files with same primary name but different secondary name are created
# e.g. file 'test.DAT1' is onverted to 'test.DAT'
# LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
for file_name in `ls /test/*.DAT1`
do
new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
# SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
# ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
# REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
# $? returns 0 if the call to gawk command is succesfull
if test 0 = "$?"
then
rm -f $file_name
fi
done
# END LOOP ON /test/ DIRECTORY
---THE CALL TO THE PROCEDURE --
SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
SQL>SET SERVEROUTPUT ON SIZE 1000000
SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
now, the statement 1 is the path of the Shell Script ecs_script.sh
which uses gawk command and does some operations on some file..
but when i give the call in Statement 1 its giving error like
/bin/sh is not a directory
so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
Please Help.@ Bhagat & Michaels
Dear Friends,
I changed my shell name as per ur suggestions
and recompiled the Java class source with
finalCommand[0] = "/bin/bash"; instead of finalCommand[0] = "/bin/sh";
and then recompiled the host procedure
executed the host procedure as per ur suggestion as follows (with out put)
SQL> exec host('/bin/bash ecs_script.sh')
PL/SQL procedure successfully completed.
bt, bt, bt, it still did not do any operations defined in the "ecs_script.sh"
in fact the script did nt executed.......
pls help , I am loosing my time..
regards. -
Executing Shell Scripts through PL-SQL
Hi All,
I am trying to execute a shell script from PL-SQL but I am not getting it right .
the code i used is as follows
----JAVA CLASS ---
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
if (isWindows()) {
finalCommand = new String[4];
// Use the appropriate path for your windows version.
finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
//finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
else {
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
new Thread(new Runnable(){
public void run() {
BufferedReader br_in = null;
try {
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
br_in.close();
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
finally {
try {
br_in.close();
} catch (Exception ex) {}
}).start();
new Thread(new Runnable(){
public void run() {
BufferedReader br_err = null;
try {
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
br_err.close();
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
finally {
try {
br_err.close();
} catch (Exception ex) {}
}).start();
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
--- THE PERMISSIONS ---
call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
--- THE SHELL SCRIPT IS -----
#!/bin/sh
# This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
# and the sends the single line stream to the new file with the use of 'gawk' command
# so finaly the files with same primary name but different secondary name are created
# e.g. file 'test.DAT1' is onverted to 'test.DAT'
# LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
for file_name in `ls /test/*.DAT1`
do
new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
# SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
# ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
# REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
# $? returns 0 if the call to gawk command is succesfull
if test 0 = "$?"
then
rm -f $file_name
fi
done
# END LOOP ON /test/ DIRECTORY
---THE CALL TO THE PROCEDURE --
SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
SQL>SET SERVEROUTPUT ON SIZE 1000000
SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
now, the statement 1 is the path of the Shell Script ecs_script.sh
which uses gawk command and does some operations on some file..
but when i give the call in Statement 1 its giving error like
/bin/sh is not a directory
so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
Please Help.The Java proc says:
> finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
You call it as follows:
SQL>exec host('/root/sh ecs_script.sh');
The final command will be:
/bin/sh -c /root/sh ecs_script.sh
Is this what you intended? -
Host in forms 10g and execute shell script
Hi!
I have a little problem. When I transfer form to AS through SSH protocol I want to automatically generate form on AS wit h code:
declare
lv_server_dir vc2() := /folder1/folder2;
lv_file_name vc2():= a.fmb;
host(lv_server_dir||'/ftp_gen.sh '||lv_server_dir||' '||lv_file_name);
In file ftp_gen.sh is code:
export ORACLE_HOME=myOracleHome
export PATH=$PATH:$ORACLE_HOME/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
export SQLPATH=$ORACLE_HOME/dbs
export NLS_LANG=SLOVENIAN_SLOVENIA.EE8ISO8859P2
export DISPLAY=:2
cd $1
./gen.sh $3
When I execute this command on form nothing happens.
What could be wrong?
Thanx,
BojanHi Bojan,
Executing the HOST Command will execute in the Mid Tier and nothing will show up in the Client. (other than the form go into Blocking mode). Just check out whether the Operation you wanted to do in the Mid tier is done or not. (Here it looks like you are compiling a form. So, check out that the fmx is generated.)
Alternatively to check out the proper execution of the HOST command, you can generate a file in the Mid-tier (on successful execution of the shell script) and read the file using TEXT_IO and display a message to user.
HTH. -
Problem with executing shell script on linux through java code.
i am facing problem to kill jboss process on linux that is my application requirement. for that i created one shell script that will get all the process for jboss instance and kill them when i am running that script from command prompt on linux its working perfectly.
The command i am using ---
/opt/RW9/jboss/v4.0.5.GA/bin/restartjboss.sh.
but when i am running through java code its not working.
the java code i am using is:-
pp = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", "/opt/RW9/jboss/v4.0.5.GA/bin/restartjboss.sh"});
could anyone tell me what is the problem ?
Edited by: akm198110 on Sep 2, 2008 9:24 AMI got the problem after long struggle ,after doing proper path i am able to execute the shell script..
-
Executing shell script through PL/SQL
Hi,
I need some help regarding execution of shell script through Oracle PL/SQL.
I have a shell script present in /abc/xyz folder with name search.sh , Through a PL/SQL procedure I am creating a file to store the report data.
I want to execute /abc/xyz/search.sh from the PL/SQL procedure to delete all files created before 3 mins .
1. At first I took Java route and got following permissions granted for RECON user.
GRANT USER SYS java.io.FilePermission <<ALL FILES>> execute ENABLED 351
GRANT USER SYS java.lang.RuntimePermission readFileDescriptor * ENABLED 350
GRANT USER SYS java.lang.RuntimePermission writeFileDescriptor * ENABLED 349
2. Then I created a simple java class for execution of OS command as below
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS
import java.io.*;
import java.util.*;
public class OSCommand{
public static String Run(String Command){
try{
Process proc = Runtime.getRuntime().exec(Command);
int ext=proc.waitFor();
return ("0");
catch (Exception e){
System.out.println("Error running command: " + Command +
"\n" + e.getMessage());
return(e.getMessage());
3. And a wrapper function as below to use this class
create or replace
FUNCTION OSCommand_Run(Command IN STRING)
RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'OSCommand.Run(java.lang.String) return int';
4. In my PL/SQL proceedure I am using following code to execute the command
v_Return := OSCommand_Run('/abc/xyz/search.sh');
to execute the shell script.
Proceedure executes without any error and generates a new csv file with report data , however shell script does not get executed and hence all csv files created earlier remain as it is in the folder.
Please help.Sven W. wrote:
What happens if you remove the catch exception block from your java command?
I asume you still might have a permission issue. But it could be hidden from you, because of the exception is catched and printed into nirvana.Executed the wrapper function OSCOMMAND_RUN as below
DECLARE
v_Return VARCHAR2(2000);
BEGIN
v_Return := OSCOMMAND_RUN('/recon/html/invoice/search.sh' );
DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
END;
And following is the result
v_Return = 0
Process exited.
In case of exception it would had printed the exception.
One more thing I noticed, even though I have taken following permissions
GRANT RECON SYS java.io.FilePermission /abc/* execute ENABLED 347
GRANT RECON SYS java.io.FilePermission /abc/xyz/* execute ENABLED 351
GRANT RECON SYS java.io.FilePermission <<ALL FILES>> execute ENABLED 352
GRANT RECON SYS java.lang.RuntimePermission readFileDescriptor * ENABLED 350
GRANT RECON SYS java.lang.RuntimePermission writeFileDescriptor * ENABLED 349
When I create a new search.sh in /abc dir I get following error
v_Return = the Permission (java.io.FilePermission /abc/search.sh execute) has not been granted to RECON. The PL/SQL to grant this is dbms_java.grant_permission( 'RECON', 'SYS:java.io.FilePermission', '/abc/search.sh', 'execute' )
Edited by: 960702 on Sep 25, 2012 10:34 AM -
Problems with executing shell script within oracle procedure
I have procedure that's owned by Semantic user. This procedure calls job scheduler (owned by USER1) which in turn executes a shell script load_semantic.sh (owned by USER1).
Now, there is a shell script(checkCount.sh)inside of this one (owned by this USER1) that has following contents:
checkCount.sh
#!/bin/bash
MODEL=$1
sqlplus -S user/pass << EOF
whenever sqlerror exit 1;
set echo on
set verify off
MERGE INTO SEMANTIC.COUNT_STATISTICS s
USING (SELECT '$MODEL' AS MODEL, 0 AS NEW_COUNT, SYSDATE AS NEW_DATE, 0 AS OLD_COUNT, SYSDATE AS OLD_DATE FROM dual) t
on (s.MODEL = t.MODEL)
when not matched then
INSERT (s.MODEL, s.NEW_COUNT, s.NEW_DATE, s.OLD_COUNT, s.OLD_DATE)
VALUES (t.MODEL, t.NEW_COUNT, t.NEW_DATE, t.OLD_COUNT, t.OLD_DATE);
COMMIT;
UPDATE SEMANTIC.COUNT_STATISTICS SET MODEL = '$MODEL', NEW_COUNT = (SELECT COUNT(*) FROM TABLE(SEM_MATCH('{?s ?p ?o}',SEM_Models('$MODEL'),NULL,SEM_ALIASES(SEM_ALIAS('','http://VISION/DataSource/SEMANTIC#')),NULL)) ),NEW_DATE = SYSDATE,
OLD_COUNT = NEW_COUNT, OLD_DATE = NEW_DATE WHERE MODEL = '$MODEL' AND NEW_DATE = (select max(NEW_DATE) from SEMANTIC.COUNT_STATISTICS where MODEL = '$MODEL');
COMMIT;
exit;
EOF
So when I execute SEMANTIC.PROCEDURE:
SEMANTIC.PROCEDURE => USER1.JOBSCHEDULER =>USER1.load_semantic.sh =>USER1.checkCount.sh
It never populates the table SEMANTIC.COUNT_STATISTICS.
I tried giving all of the permissions but I am probably missing something...
Maybe fresh eyes can see something that I can't.I can't believe I am going to say this but the reason it was not working was because I removed oracle environment path from my script by mistake.
. /etc/profile.d/oracle.sh
Ugh...
Now it is working perfectly.
Btw, sqlplus does know about shell environment variables.
THANK YOU GUYS!!! YOU ARE THE BEST!!!!!!!!!!!!!!!!!!
I ONLY HAVE YOU TO TALK TO WHEN I AM STUCK ON A PROBLEM. -
How will execute shell scripts from AR91
hallo, please help me to find where I can configure the execution mode for scripts called als run-Script in acroread.
Following scenario: a pdf file (see attachement testpdf.pdf), generate from pdflatex (see testpdf.tex.txt) calls a bash script beispiel.sh (see attachement beispiel.sh.txt). Dependend from situation opens an editor window or an xterm. Under GNOME can we not open the xterm, there start only editor windows - gvim/emacs/kwrite, but not well defined. With acroread7 opens a xterm after menu dialogs. How can i configure an defined behaviour ?
Thanx for any help
Regards, MatthiasHi Matthias,
To achieve this you can try to change the default "Open With" settings of .sh files to "xterm" as highlighted in the snapshot below
This will enable to execute any shell script in xterm.
Let us know if this helps.
Thanks,
Vaibhav -
Execve: Exec format error to execute shell script
I made job to execute a shell script.
exec dbms_scheduler.create_job (
job_name => 'run_sh',
job_type=>'EXECUTABLE',
job_action=> '/fsoracle/app/oracle/inst2/if_cft/send_file_susin.sh',
start_date=>sysdate + 1/5760,
enabled => TRUE
send_file_susin.sh
#!/bin/ksh
set -v
. /fsutil/ndm/axway/profile
/fsutil/ndm/axway/Synchrony/Transfer_CFT/bin/CFTUTIL << EOJ
CONFIG TYPE=COM,MEDIACOM=TCPIP,FNAME=$CFTTCP
SEND PART=ZADA,IDF=1363X1364,
FNAME='/fsoracle/app/oracle/product/rdbms/log/KFG.DD.SHRCOM.HRD.A03',
NFNAME=KFG.DD.SHRCOM.HRD.A03,
FLRECL=25,NLRECL=25
SWAITCAT SELECT='IDTU=="%_CAT_IDTU%"'
EOJ
This script is well executed in terminal mode, but it threwed error, [ORA-27369: job of type EXECUTABLE failed with exit code: Unknown error STANDARD_ERROR="execve: Exec format error"] when I executed the shell script, send_file_susin.sh.
I changed owners and chmods of some specific files, and t.sh was well executed.
t.sh
#!bin/ksh
/usr/bin/mkdir /tmp/test
I don't know what's wrong with the script, send_file_susin.sh.
Does any know about this? Please, tell me the solution.
Thanks in advance,
Jinbae Kim.Hi,
Posting this in case anyone else find it.
The key error here is "execve: Exec format error" .
The following things should be checked
- that the shell script is a text file has UNIX line terminators
- that the shell script is set to be executable by the user that the job runs as
- that the shell script begins with a hashbang line - e.g. #!/bin/sh (I suspect this is the problem)
For running external jobs on 10gR2 or below, refer to this post Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files
For running external jobs on 11g and up, please use a credential.
Hope this helps,
Ravi. -
ABAP program to execute shell script !
Hi Friends,
I have created some shell scripts and need to be executed through ABAP prog in order to automate some process. can any one tell me how to execute these scripts through ABAP program? i know that we have to setup those scripts through SM69 but i dont have clear idea about this.can some one tell me step by step how to do this. ur help will be awarded in terms of points.
ThanksDefine the scripts as commands in SM69. Test them in SM69/SM49 to see if they work.
Next, go to SE37, run FM SXPG_COMMAND_EXECUTE, and specify your command there. Does it work?
If yes, you can just code a 'CALL FUNCTION' to this FM in your ABAP program, and you are ready to invoke your script from your ABAP.
For a list of functions that work with commands (defined in SM69), do a drop-down on SXPG_COMMAND* in SE37.
A sample code may look like this
concatenate zsys_id z_infile z_extfile into parm
separated by space.
*C_FTP_COMMAND is a script defined in SM49
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = C_FTP_COMMAND
ADDITIONAL_PARAMETERS = parm
OPERATINGSYSTEM = SY-OPSYS
TABLES
EXEC_PROTOCOL = PROT
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
WRONG_ASYNCHRONOUS_PARAMETERS = 12
CANT_ENQ_TBTCO_ENTRY = 13
JOBCOUNT_GENERATION_ERROR = 14
OTHERS = 15.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
write: /, 'FTP Function module executed with no errors.'.
ENDIF. -
Execute Shell Script from OWB Process Flow
I am trying to execute a Shell Script from a User Defined activity of OWB Process Flow. As I have not done such things earlier
I need to know:
1. Where I will put the Shell Script (move_file.sh)?
2. What are the values in need to enter in the external process parameters (such as Command, Script, Result Code, Parameter List, Sucess Threshold etc)
Please reply this thread. It would be a big help for me and probably for others as well.
Kind Regards
Zakir
Message was edited by:
ZakirCheck this out,.
http://download-uk.oracle.com/docs/cd/B31080_01/doc/owb.102/b28223/ref_processflows.htm#i1173362
And answer to your question1, the shell script should be on the unix server.
Regards -
How to set the time limit to execute shell script
I am using Runtime exec() method to execute a shell script
if the script hangs for long time infinitely then how to get the control
return to the program.
Thanks in advancermi_rajkumar wrote:
let me explain with an example
script name is test.sh
Runtime.exec("test.sh") this will start a new process
if (proc.waitFor() == 0) {
try {
InputStreamReader isr = new InputStreamReader(proc.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
outputBuf.append(line).append(ConfigOptions.getLineModeStr());
} catch (IOException ioe) {
if test.sh did not exit and hangs with no response
in this case proc.waitFor() will not execute try catch the control will remain if statement
my question is insteadof waiting indefinitely need to set a time out say 1 hour and kill the process that executed the scriptYou really need to read the article in the link given by another poster. Your code will not work correctly because you are waiting for the process to end before reading the stream and the processes may never end because you are not reading the stream until after it ends (you need to use muli-threading as explained in the article). If the process really did hange you could probably use destroy(); but, for now, the real problem is your code. -
Best Source of Shell Scripting
What are the best sources for learning and mastering the art of shell scripting ?
There are also some articles on OTN, maybe they're useful to you:
Guide to Advanced Linux Command Mastery Part1
Guide to Advanced Linux Command Mastery Part2
C.
Maybe you are looking for
-
Adding the send email function on a form.
Hey, This has been bugging me lately. I have tried lots of methods to try and get this form to send to a specified email, yet I cannot get my head around it. I tried integrating PHP, it worked...to some extent. Problem was that the application was no
-
When I send a picture to a group of people, it gets smaller. Why is this?
If I text a picture or video to a group of people, it shrinks to thumbnail size. But if I send it to only one person, it is a normal size. My husband who has the same phone , model and software update does not have this problem at all. What is the d
-
I am the administrator of my MacBook Pro, which I share with my kids. One of them forgot his password, so as the admin I changed it for his account, but when I try to see his account, it says I need to provide the keychain password. How can i get it
-
Can I use Oracle Reports 10g with Apps 11.5.10 version?
Apps Version is 11.5.10 Oracle Reports 10g is compatible with 11.5.10 or not? If Oracle Reports 6i is the only compatible version with 11.5.10 , from where I can download Oracle Reports 6i? Thanks in advance.
-
DV capture quality in CS3 vs CS6
I am capturing Hi8 & Digital8 footage via firewire. I recently purchased Premiere CS6 but I have an older computer that is running CS3. I would like to dedicate that PC to capturing several hundred hours of footage rather than tying up my current PC.