Sponsored Content
Top Forums Shell Programming and Scripting Need help with procedure and parameters in a script Post 302536570 by adshocker on Wednesday 6th of July 2011 01:54:33 AM
Old 07-06-2011
Quote:
Originally Posted by kshji
If not set File, it's nothing => test give error, need argument
Code:
File=""
#...
if [ -f "$File" ]

Code:
# maybe better testing: File has value and file exist
if  [ "$File" !=  ""  -a -f  "$File"  ]

Thanks.

This helped solve one of my problems.

My next problem is if I wanted to do something like

Code:
echo "This is my body message" | email -t "admin@adshocker.com" -s "Sample"

or

Code:
email -t "admin@adshocker.com" -s "Sample" << EOT
This is my body message
EOT

How should I do it?

Appreciate your help.

Thanks.

---------- Post updated 07-06-11 at 12:54 AM ---------- Previous update was 07-05-11 at 09:28 PM ----------

Never mind.

I figured out how to do it.

For anyone interested, here's my complete code.

Code:
(
  echo "From: NoReply@Adshocker.com"

  while getopts t:c:b:s:f: opt
  do    
      case $opt in
           t )   echo "To: $OPTARG";;
           c )   echo "Cc: $OPTARG";;
           b )   echo "Bcc: $OPTARG";;
           s )   echo "Subject: $OPTARG";;
           f )   File=$OPTARG;;
      esac 
  done  
  shift $(($OPTIND - 1)) # remove all options from the argument array

  echo "MIME-Version: 1.0"
  echo 'Content-Type: multipart/mixed; boundary="-1234567890"'
  echo
  echo '---1234567890'
  echo "Content-Type: text/plain"
  echo "Content-Disposition: inline"
  echo

  while read body
  do
    echo $body
  done

  echo
  echo 

  for i in $File
  do
    if [ -n "$i" ] && [ -f "$i" ]
    then
      echo
      echo '---1234567890'
      echo 'Content-Type: application; name="'${i##*/}'"'
      echo "Content-Transfer-Encoding: uuencode"
      echo 'Content-Disposition: attachment; filename="'${i##*/}'"'
      echo
      uuencode $i $i
    fi
  done

  echo
  echo '---1234567890--'
) | sendmail -t

Thanks guys.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Starting a script from a Database procedure

Hey guys, I have this problem : I can run on an sqlprompt !ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous which will ftp the file from Unix to an NT machine, but if I do exec shell('sh ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous') it does NOTHING. I have no... (4 Replies)
Discussion started by: vidireporting
4 Replies

2. Shell Programming and Scripting

DB2 stored procedure (with input parameters) from script

I have a db2 stored procedure on my database which require 3 parameters, I have the following db2 command in a sql script CONNECT TO SAMPLE; CALL BACKUP(INPUT_1, INPUT_2, INPUT3); Usually, I would just invoke this sql script from my shell script like below db2 -tf... (1 Reply)
Discussion started by: mpang_
1 Replies

3. Shell Programming and Scripting

Passing parameters form unix to Oracle procedure

Hi, I have screen which was desined in PL/SQL Catridges in apps. In that screen some enterable fields these values r the passing parameters to create value sets, functions, menus etc in apps by using front end screens. Now in that screen i have a button. when i click that button it have to... (0 Replies)
Discussion started by: rajasekharamy
0 Replies

4. Shell Programming and Scripting

calling procedure from script

Hi All, My script will call a storedprocedure #!/bin/bash # # Script for ........... . ../conf/setting.env # Environment file to set the DATABASE #TODAY=`date '+%Y%m%d_%H'` #echo TODAY = $TODAY sqlplus -s $DATABASE <<EOF spool $TRACKING_LOGDIR/CalcFreqPgsVues_H.log exec... (3 Replies)
Discussion started by: scorpio
3 Replies

5. Shell Programming and Scripting

getting proper o/p from a procedure in a script

foll. is my code snippet. #!/bin/ksh retVal=`sqlplus -s user/passwd@oracle_sid <<EOF SET SERVEROUTPUT ON SIZE 100000 DECLARE STATUS_VALUE CHAR; BEGIN SELECT temp1 INTO STATUS_VALUE FROM sai; DBMS_OUTPUT.PUT_LINE(STATUS_VALUE); END; / SET... (1 Reply)
Discussion started by: sainathdeg
1 Replies

6. Shell Programming and Scripting

Executing Procedure from shell script..

Hello, I created a sql file to create a Procedure, and it was successfully created. I created a sql file to execute the procedure, and it did without any errors, but i dont see the data been updated. The Execute procedure.sql script is: BEGIN set serveroutput on size 1000000 execute... (5 Replies)
Discussion started by: msrahman
5 Replies

7. Shell Programming and Scripting

How to get OUT parameter of a stored procedure in shell script?

I am invoking a SQL script from shell script. This SQL script will invoke a stored procedure(which has the OUT parameter). I want to have the OUT parameter in the shell script as a variable. Is this possible? (6 Replies)
Discussion started by: vel4ever
6 Replies

8. Shell Programming and Scripting

Executing procedure using script

Hi, I want to have a automted script to exceute 20 procedures one by one. Suppose below is one procedure once it get executed script will write "PL/SQL procedure successfully completed." to a log for ex- exec dbms_stats.gather_table_stats(); Now later procedure starts executing... (1 Reply)
Discussion started by: sv0081493
1 Replies

9. Shell Programming and Scripting

Sub script calling procedure

Hi, I have a doubt regarding how sub scripts will be executed and interested to know internal workflow, For example - My main script is A,it calls a script B then B will call some C....and so on. Then B script run parallel to A or it will wait B to execute then A will continue. ... (1 Reply)
Discussion started by: nag_sathi
1 Replies

10. Shell Programming and Scripting

Why i can't execute the procedure in shell script?

i have the following code inside a shell script .prog in oracle server when i call the program DBMS_OUTPUT.PUT_LINE(x_return_status|| ln_rep_req_id); will return 0 , it is very strange , i try to submit the concurrent request in oracle , and it can successfully executed, what am i missing ? i... (1 Reply)
Discussion started by: feilhk
1 Replies
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy