Use wget to automate Project Tracker queries and reports

When you need to run a saved Project Tracker query or report repeatedly, you can write a shell script.

You can do this, using the wget utility to automate the process of running the query or report and exporting it to a spreadsheet format, from which it can be easily extracted for analysis by an external tool, such as a spreadsheet.

Wget is a network utility to retrieve files from the Web using http and ftp, the two most widely used Internet protocols. It works non-interactively, so it will work in the background, after having logged off. For more information about wget, see the wget Web site.

Note: To use this example code, you must have wget 1.10 or later installed locally. You will also need a working knowledge of Project Tracker, HTML, HTTP, and shell scripting.

Note: If you are using RedHat 9, please note the wget binary shipped with RedHat 9 is known to have problems with client certificates.

To create a script, follow these steps:

  1. If you do not already have saved reports or queries that you wish to execute through a script, you must create them and record the URL for their output. To create a report of query and get the URL, follow these steps:
    1. Log into the project through the web interface.
    2. Create and save the queries and reports that you want your script to execute.
      • The scope of the saved queries/reports should be "Personal."
      • Configure the saved queries/reports so that the results are exported to a MS Excel or TSV file.
    3. Go to the appropriate page to see your saved query or report.
      • To get the URLs of saved queries, go to the Saved query list page.
      • To get the URLs of saved reports, go to the Saved report list page.
    4. Use your browser's "View page source" function to pull up the raw HTML source view of the page and locate the name of your query in the "source" page.
    5. Note: The string follows the pattern <a href="[URL]">[query name]</a>. Copy only the [URL] portion of the string to use in your script.

  2. Use this command to log into the domain:

    wget --save-cookies /tmp/cookies --keep-session-cookies '[domain name]/servlets/TLogin?Login=Login&loginID=[username]&password=[password]'

  3. Notes:

    • If your site uses SSL, consider using the --no-check-certificate option to bypass the certificate check. Use this option only if you have some other way to determine the authenticity of the server. For help using wget with SSL, see the wget documentation.
    • For SSL-enabled sites, the URL should be prefixed with the https:// scheme.
    • When you log into the domain through a script, the login information is passed via URL. The username and password must conform to the rules for a URL, i.e., no unencoded spaces, underscores, or other prohibited punctuation. While special characters are not generally found in usernames, the domain may require that they be used in passwords. If the password uses special characters, it must be properly encoded.
    • Your password (marked here by [password]) will be visible to anyone who can see your scripts.

  4. Use this command for your script to execute the saved query/report. This command executes the query/report and saves the response to the file you specified in [filename]. The [project name] corresponds to the name of the project, where the saved query/report resides. wget -O [filename] --load-cookies /tmp/cookies 'http://[project name].[domain name]/[URL]'

Note: Although the example commands above are specific to wget, you can use any scripting or programming language to script Project Tracker to export data. The sequence of operations remains the same for any scripting or programming language you would use to drive an export.