function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
msimondsmsimonds 

Examples of .BAT files and how to setup automated process!

I have been looking for, and unable to find, any examples of how to setup an automated extraction process.
 
I have successfully ran the CLI from the Appexchange Data Loader and have seen results in .CSV files. 
 
I really have no clue on how or what to put in a .BAT file or .SH file (we are going to be moving this application to a linux box)
 
Can someone please point me in the right direction or post an example process/tutorial on how this is done
 
I have checked both the blog linik >  http://blog.sforce.com/sforce/2005/06/sforce_data_loa.html and the .PDF document, there are no examples here, infact the documentation is not really clear and the blog has not been updated lately.
 
Any help would be appreciated!
 
Thanks
Mike
zen_njzen_nj
Here is what I did on my end on the unix machine which uses the shell script (i.e. .sh).

On my environment, the configuration file (config.properties) used by AppExchange DataLoader is stored under
/home/sforce/conf.

And I've created s shell script under /home/sforce that is called LoadSFData.sh and in that script, it really just contains this line of code:

java -Xms256m -Xmx256m -Dsalesforce.config.dir=/home/sforce/conf -jar sforcedataloader.jar

To automate this, you would put this shell script in cron (unix scheduler tool) or via autosys.

What you'll need to do is to modify the /home/sforce/conf/config.properties file to have the proper SQL logic you want to do and specify what is
the name of the output/target csv file name.

And if you plan to run multiple jobs to export stuff from salesforce.com, you may want to create different scripts that contain logics for you to essentially
copy/overwrite the config.properties file.

So in your /home/sforce/conf directory, you may have 2 different sets of config.properties file - each would be running say export on different
tables (say Accounts, Contacts). And so you would have one called config.properties_for_Accounts and another called config.properties_for_Contacts
and in the files, your SQL statement would be referencing the columns you want for Accounts or Contacts.

Then you would have two scripts containing something like this:

script 1 - LoadSFAccountData.sh would have this logic:
cp /home/sforce/conf/config.properties_for_Accounts /home/sforce/config/config.properties
java -Xms256m -Xmx256m -Dsalesforce.config.dir=/home/sforce/conf -jar sforcedataloader.jar

script 2 - LoadSFContactsData.sh would have this logic:
cp /home/sforce/conf/config.properties_for_Contacts /home/sforce/config/config.properties
java -Xms256m -Xmx256m -Dsalesforce.config.dir=/home/sforce/conf -jar sforcedataloader.jar

Where cp is a unix tool that copies/overwrite one file to another. Since the AppExchange DataLoader is looking for a file called config.properties in the
designated salesforce config directory, the script needs to copy/overwrite that config.properties with the necessary script.

Alternatively, you could have just created different config directories (like /home/sforce/AccountLoad_config and /home/sforce/ContactLoad_config) and
in those directory you would have different config.properties file and in that case, your script would just be sourcing a different directory without having
to 1st overwrite the config.proerpties file.


On the Windows world (with .bat), it would be similar method, except you would be referencing something like C:\salesforce\config directory instead of
/home/sforce/config directory and you would use the window scheduler to run/automate yourAppExchange DataLoader process.

Hope this helps.



msimondsmsimonds
Hey thanks, those are perfect examples sir, I truly appreciate this!!!
jimmijamzjimmijamz
Within Windows,
how do you create a batch file which will call one process after the other?

After my first extraction runs, the process just stops and doesn't call the next batch line.
How do i get around this?

Code:
c:
cd\"Eclipse\dataload9\bin\"
process ../conf csvExp_User
process ../conf csvExp_Account

 

zen_njzen_nj
Not all that familiar with windows batch file.  I would have thought it would worked fine having the series of
command all in one batch file. But maybe the dataloader command line tool can only be run one at a time from one .bat file for some reason.

In your example, you have:

process ../conf csvExp_User
process ../conf csvExp_Account
I am sssuming that the process  .. just the cmd line you execute to run the extraction and there isn't actually a program command called process, yes?

So what about trying to create one batch file (i.e. Extract_User.bat) and in that batch file have line 1.
And then have another bacth file (i.e. Extract_Account.bat) and in that batch file have line 2.

Then just have the master batch file do something like:

cd \Eclipse\dataload9\bin
echo "Running Extract_User.bat now"
Extract_User.bat
echo "Running Extract_Accoutn.bat now"
Extract_Account.bat

And see if it will work - see if you at least are getting the two echo statements or if it's just hanging after you ran Extract_user.bat but no going beyond that.

Alternatively, you may just want to have two separate batch files, one to run each command - I assume that
separately they work fine?  And then use window scheduler to schedule one job after the other.