0

I have script that populates tables with data. I need to record in another table STATS, when it started loading and when it completed the load.

So in the first script I stored timestamp into variable:

**script1.sh**
    dtMODEL=$(date +"%d-%b-%y %H.%M.%S.%N %p")
    ./load_table.sh source1
    ./load_table.sh source2
    ./record_table_load_stats.sh MODEL $dtMODEL

**record_table_load_stats.sh**
   #! /bin/bash
   #
   . /etc/profile.d/oracle.sh

   MODEL=$1
   START_DATE=$2
   echo $MODEL
   echo $START_DATE
   sqlplus -s username/password<< !
   /* this is where I wanna use START_DATE variable and populate table*/

when I do:

echo $dtMODEL

15-Oct-13 13.56.46.677879674 PM

but when I pass it to record_table_load_stats.sh, it echoes

15-Oct-13

why?

1
  • I need to pass the entire timestamp: 15-Oct-13 13.56.46.677879674 PM Commented Oct 15, 2013 at 17:55

1 Answer 1

1

The way shell evaluation works, it will first substitute the contents of a variable, and then parse the command line into space-separated arguments. To override this, you have to quote the spaces in the variable contents.

Most convenient is to add " quotes around $dtMODEL, i.e.

./record_table_load_stats.sh MODEL "$dtMODEL"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.