[SORRY] exec command problem for shell scripting
I know this is not an appropriate place to ask questions about shell programming, but I have tried many other places... and no helpful help yet. So, here I am.
I am writing a simple shell script that would actually execute a java application. However, I want to give the users the option of running it in background. So,
COMMAND="java blahblah"
DAEMON="&"
exec "$COMMAND $DAEMON"
But, when I run it, it spits out an error message saying something like "Invalid agrument: &".
Is there a way to exec'ing "java blahblah &" using variables as arguments to "exec" command???
OR is it even NOT possible?
This problem seems so trivial, but took a man out of me. :( Please help.
thanks
yosep
execute a java application. However, I want to give
the users the option of running it in background. It doesn't generally make sense to exec an ansynchronous process, and one can introduce varying errors in this method. Just simply drop the exec. The java process will async off and the shell script will exit leaving no shell process running. Simple as that.
BTW, you generally exec a java process if you wish to replace the shell with the java process, but then the async request is given at the caller, she who actually calls the script (genarally from an interactive shell).
Similar Messages
-
Exit command in a Shell Script
I am trying to input an 'exit' command in a shell script. I am running Solaris 8. I have checked all of my documentation on the OS and cannot find the command syntax. Can someone help me? Thanks.
#!/usr/bin/env bash
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
port selfupdate
# The second step is to upgrade the outdated
echo "Step 2: Upgrade outdated"
port upgrade outdated
# The third step is to remove inactive ports
echo "Step 3: Remove inactive ports"
port uninstall inactive
# The fourth step is to clean the vile
echo "Step 4: Clean the vile"
port clean --all vile
Now invoke your script using sudo, as in:
sudo ./macportsUpdate.sh
This way you authentiate once, and from that point forward everything is run a 'root'
If you do not want to remember to prefix the script with sudo, then you could do the following:
#!/usr/bin/env bash
myPortUpdate()
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
port selfupdate
# The second step is to upgrade the outdated
echo "Step 2: Upgrade outdated"
port upgrade outdated
# The third step is to remove inactive ports
echo "Step 3: Remove inactive ports"
port uninstall inactive
# The fourth step is to clean the vile
echo "Step 4: Clean the vile"
port clean --all vile
# Now do all of the above with a single sudo command
sudo myPortUpdate
Now you can invoke the script and it will just prompt once for your admin password
macportsUpdate.sh
Message was edited by: BobHarris -
Run Unix command / Run Unix shell script from Forms9i
Hi,
I have a requirement to run Unix command and Unix shell scripts from Forms9i.
I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
Please point me towards any other way to achieve the same.
I would really appreciate your help.
Thanks,
KumarThere is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands. -
Printing problem for SAP Script
Dear Friends,
I am facing strange problem for SAP Script. In the billing document output the sold to party and ship to party address are displaying. When user print the billing document on laser printer it print the Country for Sold to and Ship to. But when it print the same billing document on normal printer (other than laser) the Sold to country not printing.
The print preview of billing document in SAP correctly display country for Sold-to and Ship-to.
I have recently make changes in the SAP Script form (Address window) to display country for Ship-to which was never displayed before. I have added FROMCOUNTRY option after COUNTRY in address window. COUNTRY will be Ship-to and FROMCOUNTRY will be VBDKR-SLAND.
Can any one help me to solve this problem.
Regards
Nilesh SheteUsed custom address print option instead of using ADDRESS
-
Problem executing shell script for rwrun
hi..
I wrote a shell script to make a report similar to the batch file in windows.
My OS is Suse 8.0 with oracle installed in it..
I have the script like this..I used 2 lexical parameters for my rep file.
/opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer=\'Ludwigsburg\' and\'
This one works fine but the one below doesn't give any output. The pdf fiel is just empty. I wonder y,,may be any problems with the spaces or escape characters.I didn't get any error when executed the scripts.
/opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer like \'L%\' and\'
thanx and waiting for soem one to answer..
regards
KoviI solved it by doing the following..
opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\\'\\' whereford=\\'\\ protokolle.haendlernummer\\ like\\ \\'L%\\'\\ and\\'
from the Java Program..
Important thing I discoverd is there should be a space at the beginning like whereford=' prot...' and it sok now..
thanx ...but I still has other probelm now..which is to invoke the report from a servlet which executes this shell script..Problem with DISPLAY variable..I cannot run rwrun.sh without DISPLAY variable..
Is there any way to set this variable for tomcat service. -
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 -
OS Problem executing shell script
Hi,
I am executing a shell script using 'Runtime.getRuntime().exec()'. I need to view the iteration data on my shell as the execution progresses.
I get the input streams from the process and buffer them in order to do this.
I can see the progress successfully on SunOS, but not on HP. The shell script itself runs fine on HP.
Any possible solution to this is greatly appreciated. I searched the forum and also some other sites like Java World, but haven't found anything useful yet.
Thanks.Here's a detailed explanation of the problem:
I have a shell script that makes a single call to a executable. The output is piped to the shell one line at a time(number of lines depend on the number of iterations I specify in the script). This shell script run by itself works on Unix SunOS and on HPUX 11 with the output piped to the shell as the execution progresses.
I am trying to execute this shell script from my java code. For this I use the "runtime" environment, and get the output from the "process" using the "getInputStream" and "getErrorStream" methods. I buffer these streams using "BufferReader", and output them to the shell.
My code works as desired on Sun OS, with the output from the process piped to the shell one line at a time as the execution progresses. But on HPUX 11, the output is piped to the shell all at one time - after the process runs to completion. I am not able to understand this behavior.
Hope my description of the problem is clear. Thank you. -
Problems using Shell scripts and Automator
My problem is that when I use the "Run Shell Script" Automator action, it won't work if I type the script inside the action but it will work if I just type a path to the script file, which is less elegant as I then need to copy the Automator app made as well as the script file.
Here is the script I am trying to use
#!/bin/bash -f
if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
then
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
else
ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
fi
exit 0Well I found the problem. Or at least I got it to work. I tried typing simple commands and scripts into the Shell Script action and had no issues with it running. So I then slowly expanded and typed out my script:
#!/bin/bash -f
if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
then
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
else
ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
fi
exit 0
Having typed it out in the script it runs fine. It seems you can't paste text into the action. To test this hypothesis, I copied the working script out of automator into BBedit and then back into Automator, the script no longer worked. Not sure why that is happening, but it does work if I type the scripts out. -
Problem from shell script to java class
Hello All,
I have a shell script (P.sh) which is having the following code.
. setEnv
echo first param: $1;
echo second param: $2;
runClient Abc $1 $2
If in Abc class I write the following code.
System.out.println("Arg length " + args.length);
It gives me Arg length as 1 even though on command line I write
P.sh a b
Why am I getting the error that is not getting the second argument?
Hoping for a reply.
Thanks and regards,
Sachinit is java command written in a different fileI don't understand. Is it yet another script or a renamed java executable?
-
Parameters for Shell Script running DBMS_SCHEDULER as Executable
Hi,
I have a shell script to run through DBMS_SCHEDULER.
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'PROGRAM_NAME',
program_type => 'EXECUTABLE',
program_action => '/home/oracle/test.sh',
enabled => TRUE,
comments => 'Test Shell Script'
But how do I define the parameters for the shell script?
Lets say if I run the shell script from the Unix promt I will enter as below:
/home/oracle/test.sh -d aed5 -p "XYZ"
How do I define it in the DBMS_SCHEDULER.define_program_argument?
Thanks in advance,
Samujjwal BasuRe: Excute Unix command Using PL SQL might help.
-
How to solve this problem in shell script: unexpected end of file
Hello,
I need to connect to each databases listed in /etc/oratab and check which database is shutdown(or mounted-only) and which database is opened to accept connection. However, following shell script gives me this error message:
$>./check_is_db_runing.sh
./check_is_db_runing.sh: line 39: syntax error: unexpected end of file
Could anyone please help me to solve this problem, why the code (line 29 to 32) does not work in the LOOP? It works without the LOOP.
Thanks in advance!!!
1 #!/bin/bash
2
3 LOGDIR=/data03/oracle/dbscripts
4 ORATABFILE=/etc/oratab
5
6 cat $ORATABFILE | while read LINE
7 do
8 case $LINE in
9 \#*) ;; #comment-line in oratab
10 *)
11 ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
12 if [ "$ORACLE_SID" = '*' ] ; then
13 # NULL SID - ignore
14 ORACLE_SID=""
15 continue
16 fi
17
18 # Proceed only if last field is 'Y'
19 if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
20 if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
21
22 ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
23 PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
24 export ORACLE_SID ORACLE_HOME PATH
25 LOGFILE=$LOGDIR/check_$ORACLE_SID.log
26 touch $LOGFILE
27 #echo $LOGFILE
28
29 $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
30 select * from global_name;
31 exit
32 EOF
33
34 fi
35 fi
36 ;;
37 esac
38 doneThis code works ie. generates logs with sql result - slightly modified to be runable:
#!/bin/bash
LOGDIR=/tmp
ORATABFILE=/etc/oratab
cat $ORATABFILE | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
if \[ -z $ORACLE_SID \] ; then
# NULL SID - ignore
ORACLE_SID=""
continue
# Proceed only if last field is 'Y'
else
ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
export ORACLE_SID ORACLE_HOME PATH
LOGFILE=$LOGDIR/check_$ORACLE_SID.log
touch $LOGFILE
#echo $LOGFILE
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
select * from global_name;
exit
EOF
fi
esac
done -
I'm looking for a logical place to save Unix shell scripts. ~/Documents doesn't sound right, nor would ~/bin because the scripts aren't binaries. I know it comes down to personal preference, but what makes the most sense, ~/Library/Scripts? and /Library/Scripts for all users?
I've been using Unix since '85, and here is what I do:
~/local/bin # for my personal scripts and executables
/usr/local/bin # for my shared scripts and executables
And I also create a symlink ~/bin that points to ~/local/bin
cd ~
ln -s local/bin bin
Many open source applications are stored by default in /usr/local/bin, but from time to time, I'm on a Unix system I do not own, and I want to install a personal open source program, so I use
./configure --prefix=$HOME/local
which will configure the open source software so it is setup to store things in my home directory, including any support files, man files etc... associated with the program. For example a personal copy of Vim. -
Substitute for shell scripts in windows?
In linux, I believe shell scripts would be useful for simulating user load on oracle. But in windows what could serve that purpose? Dos?
In windows it's called batch file scripting
run these script in cmd mode. similiar to a DOS screen
type cmd at Start--> Run
http://labmice.techtarget.com/articles/batchcmds.htm -
Translating working UNIX command to "do shell script"
A few days ago LittleSaint and Gary Kerbaugh (UNIX discussions) suggested an approach for text positioning which appears to work flawlessly in Terminal. The UNIX version is:
awk -v str_x="140 280" -v str_y=abcdef 'BEGIN{ printf "%-13s%s\n", str_x, str_y }'
Now, I'm trying to use this in AS as a "do shell script". Clearly, some changes are needed (characters escaped, punctuation changes, etc.), but I've been unable to nail down exactly what those are (assuming it's even feasible).
Ideas?How about this:
do shell script "awk -v str_x=\"140 280\" -v str_y=abcdef 'BEGIN{ printf \"%-13s%s\\n\", str_x, str_y }'" -
Parameters for Shell Script running through DBMS_SCHEDULER as Executable
Hi,
I'm using Oracle 10.2.0.1 on Solaris.
I have a shell script to run through DBMS_SCHEDULER.
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'PROGRAM_NAME',
program_type => 'EXECUTABLE',
program_action => '/home/oracle/test.sh',
enabled => TRUE,
comments => 'Test Shell Script'
But how do I define the parameters for the shell script?
Lets say if I run the shell script from the Unix promt I will enter as below:
/home/oracle/test.sh PITS aed5 XYZ
How do I define it in the DBMS_SCHEDULER.define_program_argument?
Thanks,
ShailWhen you create the program you define the number of parameters it will accept:
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'PROGRAM_NAME',
program_type => 'EXECUTABLE',
program_action => '/home/oracle/test.sh',
enabled => TRUE,
comments => 'Test Shell Script',
number_of_arguments => 3
);then you define your job arguments and set default values. This is optional - but if you don't then you will have to define the values using the set_job_argument_value:
-- defines the first argument
DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
program_name => 'PROGRAM_NAME',
argument_position => 1,
argument_name => 'arg1',
argument_type 'CHAR',
default_value => 'PITS',
);You can set the argument vaues using:
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'JOB1',
argument_position => 1,
argument_value => 'PITS');or using the argument name defined using the define_program argument
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'JOB1',
argument_name => 'arg1',
argument_value => 'PITS');where JOB1 is a job for program PROGRAM_NAME created using the dbms_scheduler.create_job procedure
see docmentation: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm for more details...
Maybe you are looking for
-
Threaded Email NOT working since upgrading to Lion
Threaded emails were working fine until I upgraded to Lion. I have even done a fresh reinstall, enabled classic view, organize by conversation, and adjusted the view setting in the preferneces to include related messages. While my replies are groupe
-
Full screen gradient - poor quality?
Hello Forum I'm using actionscript 2 to create a full screen gradient across the screen as a background. (see code below). It looks ok, but if I look closer the quality is not that great. It doesn't seem to have enough colors to create a smooth trans
-
Is there a way to show an icon for URL items? I like the mime-type icons for documents (pdf, doc, etc) and I would like something similar for URLs. Wikipedia, for example, has little box-arrow icons next to links to indicate that it's an external lin
-
Needto find no. of valid and invalid objects in a tablespace
Hi, Can anyone tell me how to find the no. of objects that are valid and invalid in a tablespace.Below are the 2 tablespace that i want the info for SQL> select 2 fs.tablespace_name "Tablespace", (df.totalspace - fs.freespace) "Used MB", 3 4
-
Hi, We are currently on ERP version 4.6c. I am trying to configure Address Management in SAP. The purpose of using it is that when creating vendor/customer masters, the addresses should be validated by Address management (through USPS database which