sqoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandipan.Ghosh <Sandipan.Gh...@target.com>
Subject RE: Run sqoop from .sh script
Date Thu, 10 Apr 2014 06:02:33 GMT
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:abe@cloudera.com]
Sent: Tuesday, April 08, 2014 7:26 PM
To: user@sqoop.apache.org
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 <Sandipan.Ghosh@target.com<mailto:Sandipan.Ghosh@target.com>>
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


Mime
View raw message