Hey there,

Have you tried using "set -e" in the beginning of the script to indicate a
failure to kill the script?

-Abe


On Wed, Apr 9, 2014 at 11:02 PM, Sandipan.Ghosh
<[email protected]>wrote:

>  Thanks for the suggestion,
>
>
>
> I tried to use the 1st example you gave.
>
> Here is my .sh file (saved as try_bash_sqoop.sh)
>
> sqoop --options-file /home_dir/z070061/sqoop_import_param_td.txt
> --fields-terminated-by '\t' --warehouse-dir ../../user/z070061/UDC_DPCI/
> --table inovbidt.UDC_DPCI
>
> sqoop --options-file /home_dir/z070061/sqoop_import_param_td.txt
> --fields-terminated-by '\t' --warehouse-dir
> ../../user/z070061/UDC_STR_DC_MAP/ --table inovbidt.UDC_STR_DC_MAP
>
>
>
> When I run it using below command
>
> bash try_bash_sqoop.sh
>
>
>
> it only run the last sqoop command successfully and failing the 1st one. If
> I run the command separately, then it's runs fine without any error.
>
> Attached is the code and the log file (copy from screen output)
>
> Thanks
>
> Sandipan
>
>
>
>
>
> *From:* Abraham Elmahrek [mailto:[email protected]]
> *Sent:* Tuesday, April 08, 2014 7:26 PM
> *To:* [email protected]
> *Subject:* Re: Run sqoop from .sh script
>
>
>
> Hey there,
>
>
>
> You should just be able to put your sqoop commands in series:
>
>     sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table b --split-by a
>
>     sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table c --split-by a
>
>
>
> The CLI should return 0 or 1 depending on the success of the job. So you
> can provide conditions:
>
>     sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table b --split-by a
>
>     if [[ $? -e 0 ]]; then
>
>       sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table c --split-by a
>
>     fi;
>
>
>
> Also, this means you can use "set -e" to tell the script to exit if any
> one command fails:
>
>     set -e
>
>     sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table b --split-by a
>
>     sqoop import --connect jdbc:mysql:///test --username root --password
> hue --table c --split-by a
>
>
>
> For running the commands first, then adding to a .sh file, you can
> manually add the commands you've previously ran. You can find these
> commands via bash history. Type "history" from the command line to get a
> full list of commands you've entered for your current session.
>
>
>
> -Abe
>
>
>
> On Tue, Apr 8, 2014 at 4:51 AM, Sandipan.Ghosh <[email protected]>
> wrote:
>
>
>
> Hi,
>
>
>
> I want to run multiple Sqoop commands saving into a .sh file then
> executing that from bash shell.
>
>
>
> How will I do it?
>
>
>
> Thanks
>
> Snadipan
>
>
>

Reply via email to