bash command line to export a SFDC report to CSV
Salesforce.com offers different ways to export data to flat files but it does introduce unnecessary complexity in the process.
This small bash code demonstrate how you can easily export SFDC reports to CSV by using the command line, and standard tools like curl, and sed.
- curl to call the SFDC API login entrypoint
- sed to parse the SOAP response
- curl to validate the SFDC report endpoint
- curl to export the report to CSV
-s <URL> : SFDC domain URL
-r <UID> : SFDC report unique ID
-t <TOKEN> : SFDC account token
-u <USER> : SFDC user name
-p <PASS> : SFDC password
./sfdc2csv.sh \
-s https://test.salesforce.com \
-r 00O80000005Ww9g \
-u [email protected] \
-p my_password \
-t get_your_token_from_the_account_setup_menu
It is better to store both the password and token on a file to avoid display them as clear text when calling the script. For example:
./sfdc2csv.sh \
-s https://test.salesforce.com \
-r 00O80000005Ww9g \
-u [email protected] \
-p $(cat password_file) \
-t $(cat token_file)