Small Shell Script Doubt
I Have a cmd file
i dont understand what these lines are inside that .cmd file ..
echo Starting FTP ... >> /u03/app/oracle/admin/s7/s7.log
date >>/u03/app/oracle/admin/s7/s7.log
echo ----Start Uploading the Employer Master Table---->> /u03/app/oracle/admin/s7/s7.log
echo End Date/Time ---
date >> u03/app/oracle/admin/s7/s7.log
My Question is ..are these lines are Automatically generated ?
and what is this operator in Unix *>>*
Thank you all in Advance,
Data Boy
Hey Data Boy,
the >> symbol is a redirect symbol to contatenate some output to a file. For example, what you have shown us will add the following to the /u03/app/oracle/admin/s7/s7.log file.
Starting FTP ...
Wed Nov 12 09:15:12 PST 2008
----Start Uploading the Employer Master Table----
End Date/Time ---
Note, the date is also listed from the line date >>/u03/app/oracle/admin/s7/s7.log
P.S. To re-create the file just use the > (single arrow) redirect symbol. It will delete the current file and start over. Then you can use the >> (double arrow) symbol to keep adding to the file.
Michael Cunningham
Similar Messages
-
Wireless network (and a shell script for you guys, also)
I don't know the right way to bring up my wireless iface at bootup, so I wrote a small shell script to do it for me.
Feel free to use it if you find it useful..
I'd also appreciate someone telling me what *IS* the arch way of doing what my shell script's doing
#!/usr/bin/env bash
# Val Polyakov <[email protected]>
# 7/8/07
# Change these to reflect your network
PATH=/usr/sbin:/sbin:/bin
IFACE=ifaceNameOfYourWirelessCard
DRIVER=moduleNameForYourWirelessCard
SID=yourSID
ENCKEY=yourEncryptionKey
# Don't change anything beyond this point.
case "$1" in
start)
echo "Loading the wireless card driver"
modprobe $DRIVER
echo "Setting up the SID and encryption key"
iwconfig $IFACE essid $SID enc $ENCKEY
echo "Bringing up the wireless interface"
ifconfig $IFACE up
if [ -f /var/run/dhcpcd-$IFACE.pid ]
then
rm /var/run/dhcpcd-$IFACE.pid
fi
echo "Running the dhcp client"
dhcpcd $IFACE
stop)
echo "Bringing down the wireless interface"
ifconfig $IFACE down
echo "Unloading the driver"
rmmod $DRIVER
restart)
$0 stop
sleep 2
$0 start
echo "usage: $0 {start|stop|restart}"
esac
exit 0brain0 wrote:If your wireless drivers support wpa_supplicant, you could try autowifi from http://www.archlinux.org/~thomas/autowifi-svn/ It handles multiple wireless networks very well. There is no documentation right now, just read here: http://archlinux.org/pipermail/arch-dev … 00867.html
what would the benefit of that be, as compared to my script ?
the shell script i made (and pasted) works just fine, sits in /etc/rc.d and is called by /etc/rc.conf
i was just curious whats the official, i guess, way to do it with arch
since network profiles dont work for some reason, i figured i must be missing something.. -
How to call shell script from a pl/sql procedure
Hi all,
I am little bit new to plsql programming, i have a small problem as follows
I have to call a shell script from a pl/sql procedure ..
Please suggest me some methods in oracle 10g, which i could make use of to achieve my goal. also please tell me what are the constraints for those methods if any.
I already came across dbms_scheduler, but i have got a problem and its nor executing properly its exiting giving 255 error or saying that permission problem, but i have already given full access to my shell scripts.
Thanks in advance
Best Regards
SatyaHi,
Read this thread, perhaps is there your response :
Host...
Nicolas. -
Using a UNIX shell script to run a Java program (packaged in a JAR)
Hi,
I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
loggedinuser="$(whoami)"
CFG_DIR="`dirname $0`"
EXIT_STATUS=${SUCCESS}
export PATH=/opt/java1.3/bin:$PATH
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIR
java -classpath $
EXIT_STATUS=$?
cd $OLDDIR
echo $EXIT_STATUS
exit $EXIT_STATUSHi,
I have an application (very small) that connects to
our database. It needs to run in our UNIX environment
so I've been working on a shell script to set the
class path and call the JAR file.
#!/bin/sh
exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
echo $EXIT_STATUS
exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
Harald. -
Passing parameters in a shell shel script
Hi everybody,
I am working on a task which gets report on every remote database.
I created a small database: ‘REPORTS_DB’ and I created 6 'sql' scripts on that database. While executing the first script, it calls the other 5 different 'sql' scripts. All these 5 sql scripts use a '@db_link' (hard coded) and gets that database's report to the database: REPORT_DB.
It is working good. But,
We have 42 databases and I have to get reports of all the 42 databases. Since it is not efficient to create 42 sets of sql scripts, I want to make it automated.
I know (but I don't know HOW) I can pass a parameter (database link name) while running the first script (which calls the other 5 scripts), so that the parameter replaces the @db_link in all the 5 scripts and gets the report of the related (@db_link) database.
Could somebody send me a sample shell script to do this task?
OR, is there any way to do this task without using shell script ?
(BTW, we are using korn shell on sun Solaris)
Thanks in advance.
- JTHi everybody,
I posted same question earlier for UNIX/shell script and rec'd one response. Thanks to Bob.
But the requirement has been changed and now my mgr wants the same task using PL/SQL. Could somebody help me ?
Question again....
I am working on a task which gets report on every remote database.
I created a small database: ‘REPORTS_DB’ and I created 6 'sql' scripts on that database. While executing the first script, it calls the other 5 different 'sql' scripts. All these 5 sql scripts use a '@db_link' (hard coded) and gets that database's report to the database: REPORT_DB.
It is working well. But,
We have 42 databases and I have to get reports of all the 42 databases. Since it is not efficient to create 42 sets of sql scripts, I want to make it automated.
I know (but I don't know HOW) I can pass a parameter (database link name) while running the first script (which calls the other 5 scripts), so that the parameter replaces the @db_link in all the 5 scripts and gets the report of the related (@db_link) database.
Could somebody tell me how to do this task using SQL and PL/SQL ?
OR
send me a sample PL/SQL script to do this task?
Sorry for the inconvenience and thanks in advance.
- JT -
Hi,
I have written shell script for below scenarios, can you please guide me to write this as correct way, requirment is,
1. i need to connect the database which is on unix server , but before connecting the DB some of the files needs to be removed from \tmp directory.
2. once removed the script need to connect the database and call the sql file which is in \tmp directory.
3. the output files will be stored in \tmp directory start with DB name.
4. finally csv files needs to be transferred to local windows with help of FTP. please find below the script
#!/bin/sh
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
FILE='E:\STATS\DB1.*'
cd /tmp/dbmon
ftp -n -v $HOST << EOT
user $USER $PASSWD
prompt
mput $FILE
bye
EOT
EXIT;
EOF
Thanks
Edited by: ASP on Nov 18, 2011 4:45 PMHi ASP
It's always a good idea to write entries to timestamped log file without which you will never know where the script went wrong or failed.
This is not tested but just a small example
#!/bin/sh
export LOG_DIR=/tmp/log
export LOGFILE=$LOG_DIR/`basename $0`_${TIMESTAMP}.log
if [ ! -d $LOG_DIR ]
then
mkdir $LOG_DIR
fi
echo "Removing the temporary files from /tmp/dbmon at `date +%Y%m%d_%H:%M:%S`" | tee -a $LOG_FILE
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
echo "Run SQLPlus file" | tee -a $LOG_FILE
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
echo "Now FTP the files to windows box " | tee -a $LOG_FILE
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
cd /tmp/dbmon
ftp -vn $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
ascii
cd E:\STATS
mput DB1.*
bye
EOF -
Hi,
I had a requirement to execute a long running sql query. But the sql query had some parameters to be passed in it. I want to use nohup command and run the sql script using shell script concept. How can i pass the parameters and run the nohup command. I am herewith attaching sql reference.
[http://hatchappsdba.blogspot.com/2008/01/how-to-run-rcv11isasql-type-of-files.html]
I want to keep the sql script in a shell script and run it through nohup command.
Can you please let me know how can i keep the above sql in a shell script and run through nohup commandI want to keep the sql script in a shell script and run it through nohup command.
Can you please let me know how can i keep the above sql in a shell script and run through nohup commandFrom the OS command prompt, issue:
# nohup sqlplus <username>/<password> @<script name>.sql &Or as sysdba (if sysdba is needed to run the script):
# nohup sqlplus "/ as sysdba" @<script name>.sql &Or, you can write a shell script as mentioned in this thread -- nohop sqlplus doubt
Thanks,
Hussein -
i have a doubt as to how to comment a line in a shell script as i have to do that in a config. file of Oracle 9i Application Server. Is it a "--" in a line. Please help.
regardsTry to use # as a comment in unix shell script.
The config files in Oracle AS are xml based so the comment
therefore is
<!-- This is a comment -->
Hope that helps. -
How to exec. stored procedure having out parameter value in shell script ?
Hi Gurus,
I am writing a shell script which is calling a SP having out parameter as varchar2.
So how can i do this in shell scripting ? (I am a new in shell scripting)
a simple example is preferred.
Thanks
SandySo how can i do this in shell scripting ? Assuming you want to assign the out parameter value to a shell variable, here's a small example :
SQL> select ename from emp where empno=7902;
ENAME
FORD
SQL> create or replace procedure show_name (
2 v_empno in number,
3 v_ename out varchar2)
4 is
5 begin
6 select ename into v_ename from emp
7 where empno = v_empno;
8 end;
SQL> /
Procedure created.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
$ cat show_name.sh
ENAME=`sqlplus -s test/test << EOF
set pages 0
set feed off
var V1 varchar2(30);
exec show_name($1, :V1);
print V1
exit
EOF`
echo $ENAME
$ ./show_name.sh 7902
FORD
$ -
Call Unix Shell Script From OBIEE
Hi All,
Is it possible to do a call to a Unix Shell Script with the Action Framework from OBIEE.
Thanks in AdvanceI dont think so but we can go for it instead of BI side. Try to port the same functionality on shell script side, so that the script can identify your report using tail of nqquery log and execute the rest of your lines in shell script.
This can doable and works as expected. If at all you are going with my suggestion you can go for a small key word to identify your report instead of that lengthy logical query.
Pls mark if helps -
How to use "do shell script" when Terminal replies with a prompt?
Hey all,
I'm wondering how to properly use "do shell script" when Terminal replies with a question? In this example, I'm building a small tool in AppleScript that will auto-update the Android SDK via command line prompts. The problem is when I tell it to update all ("update sdk --no-ui"), I need to accept licence agreements before it continues, and the amount of licence agreements brought up is different every time.
So, basically, I'm wondering how to handle a case where "do shell script" encounters a case where Terminal would normally need a user's response to?
Thanks,
BehnIf it is variable number of prompts that is a problem. Look around hd and figure out how many prompts there will be. Ask around android forum for a bash solution. There are some test case apps that will let you put conditionals on output from running programs.
# traditional way. Pipe output to command.
do script "echo 'ok' | update sdk --no-u"
Here is the preferred way of getting administrator privileges.
It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on. Here is an example.
Author: rccharles
For testing, run in the Script Editor.
1) Click on the Event Log tab to see the output from the log statement
2) Click on Run
For running shell commands see:
http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
on run
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
set unixDesktopPath to POSIX path of "/System/Library/User Template/"
log "unixDesktopPath = " & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
log "quoted form is " & quotedUnixDesktopPath
try
set fromUnix to do shell script "sudo ls -l " & quotedUnixDesktopPath with administrator privileges
display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
on error errMsg
log "ls -l error..." & errMsg
end try
end run -
Reg. shell script.
Hi,
I need a small favour.
Its a simple shell script.
I want to search a string in a file and after that i want to print next two or three lines after that string.
How this can be achived.
Please help me regarding this.
ex:
I have file abc.txt as shown below.
vi abc.txt
alter database open ;
SUN 16 dec 2008
aaa
ddd
Now my requirement is to print
the three lines after database open.
How can this be achived?user583972 wrote:
Hi,
I need a small favour.
Its a simple shell script.
I want to search a string in a file and after that i want to print next two or three lines after that string.
How this can be achived.
Please help me regarding this.
ex:
I have file abc.txt as shown below.
vi abc.txtLooks like you are trying to pa<sid>.log file. Maybe if we stepped back and looked at the problem you are really trying to solve, not just the technique you've already decided on, there might be a better way. In fact, depending on your real problem, Oracle may have already solved it for you.
>
alter database open ;
SUN 16 dec 2008
aaa
ddd
Now my requirement is to print
the three lines after database open.
How can this be achived? -
Automator: running forever after executing a shell script?
Hi,
so i have found this little automator workflow that will start MAMP's Apache & MYSQL servers automatically (saved workflow as app then put into my login item autostart) however the script just keeps running forever and never exits (which should prompt a small Growl notification as feedback.
The Script:
<pre class="jive-pre" style="white-space:pre-wrap;width:585px;">
on run {input, parameters}
*do shell script* "/Applications/MAMP/Library/bin/apachectl start" password "my_password" user name "jannis" with administrator privileges
*do shell script* "/Applications/MAMP/Library/bin/mysqld_safe --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lowercase_tablenames=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysqlerrorlog &"
*do shell script* "exit 0"
return input
end run
</pre>
This is what shows when it runs:
Any ideas on what I am doing wrong for it to just keep spinning the little cog wheel and not exiting?
PS: Both services are being started successfully! So the shell scripts seem to be run and doing their job just fine, just that they do not exit.
Thanks for looking.
JannisThis is a common question with do shell script. The issue is that mysqld_safe doesn't exit until MySQL shuts down, so your do shell script is hanging around waiting, essentially hanging your workflow.
The solution is to redirect the stdout and stderr of the mysqld_safe command to a temp file. This releases the hooks that do shell script has on the command allowing the workflow to continue. To do this, just append '> /dev/null 2>&1' to the end of the shell command, like:
do shell script "/Applications/MAMP/Library/bin/mysqld_safe --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lowercase_tablenames=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysqlerrorlog >/dev/null 2>&1 &"
As an aside:
do shell script "exit 0"
This line is worthless. I'm not sure what you're trying to achieve here -
Reading contents of asm through shell script
How to read contents of asm through shell script?
Please paste one small example also.
Thanks
BalaHello Bala,
The ASM contents is not visible from the operating system or its utilities. Only visible to database instances, RMAN, and other Oracle-supplied tools.
Please see http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/glossary.htm#sthref4105
Regards,
Rodrigo Mufalani
http://mufalani.blogspot.com -
Automator workflow "run shell script" keeps running. How to stop?
Because i want two instances of dropbox running simultaneously on my Mac, I set up a small automator workflow application. The workflow consist of a simple shell script:
Or in text:
bash
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
The problem is that once the application runs, or i execute the script from within automator, it just keeps running (i get the little cog in my menubar). Anybody have an idea how to automatically stop after it has launched dropbox?
Thanks!
KimI do not have dropbox on my computer, so I tested using the Calculator application. The solution proposed by Mattis S.F. does work, but his explanation does not hold true in my case. Initially, I successfully tried
HOME=$HOME/Dropbox-quivertree nohup /Applications/Calculator.app/Contents/MacOS/Calculator >/dev/null 2>&1 &
If I remove the “nohup”, the result does not change. Removal of the “/dev/null 2>&1”, however, results in the same problem originally described by Kim van der Leeuw. My guess is the background process has stdout and stderr redirected by default back to the automator. When redirected to /dev/null, the automator no longer waits for the background process to complete. To summarize, change
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
to
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox >/dev/null 2>&1 &
Maybe you are looking for
-
How to acces the filename from Message Header during variable substitution
Hi, We need to access the attribute filename from Message Header during Variable Substitution.We are able to access the following attributes of Message Header sender_party, sender_service, receiver_party, receiver_service, interface_name, interface_n
-
Navigation from ALV Record to Tcode
Hello All, I have a requirement like this, My zPROGARM is displaying one ALV output. When an user select one record/cell it has to navigate to particular Tcode . Is it Possible? Kindly advice me on this. Thankyou, Ram.
-
BPM Alert Container Elements Not Filled
Hi All, Another problem i am facing when i am raising alert from BPM. In inbox i see alert message being raised but with no text. I have also subscribed to email alerts. In the email the subject is Process 000000008058 and the content is the first al
-
Installing BIBeans on 9iAS 9.0.3 Solaris 8
I was reading in http://otn.oracle.com/products/bib/htdocs/installation/installing_bibeans.html regarding install of BIBeans on UNIX environments that require an X server or XVFB on a "headless" box. Is this the case on Sun V240's? That's what I'm as
-
MacMail has stopped noting when I have read an email. For example, I had 17 unread messages, so I read them. Despite me having read them AND deleted them, the inbox still has 17 new messages displayed. Can anyone help resolve the incorrect display