Not signed in (Sign In)

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentTimeJan 6th 2012

    Can anyone provide a basic sample script intended to be run after the web exporter is used?

    I've tried this:

    cd "$EXPORT_PATH"

    for file in $WRITTEN_FILES
    python "$file"

    It returns with error status 1, and zero output is generated. The Python script cleans up the HTML output, and it works as desired. (I did put the full system path to the Python script in the Bash script.)

    I've also made both the Bash script and the Python script executable (chmod 755).

    I'm sure it's just a simple syntactical matter—any help would be much appreciated.

    Many thanks,

    • CommentTimeJan 6th 2012
    I've tried putting all the variable in double quotes, and then I get error status 2.
    • CommentTimeJan 8th 2012 edited

    Your bash scripts looks almost correct, there's just one small caveat in bash. In bash, elements of an array (such as $WRITTEN_FILES) are separated using a variable called $IFS (internal field separator), which is set to whitespace (space, tab, and newline). Thus, all files which include a space are split. Thus, you need to set the IFS environment variable to line breaks only (see code) and reset it later (our own post-processing scripts do this already). The code also includes two lines which remove empty paragraphs (the line with the sed and the mv afterwards), which may look really nerdy but is the easiest way to do it.

    # Change to export directory.
        cd "$EXPORT_PATH"
    # Save field separator, set field separator to line breaks.
    IFS=$(echo -en "\n\b")
    # Iterate over all exported files.
        echo "$FILE"
        # Delete empty paragraphs, write to temporary file. 
        sed '/\<p\>[ \t]*\<\/p\>$/d' "$FILE" > "$FILE".old
        # Move temporary file to original file.
        mv "$FILE".old "$FILE"
    # Restore field separator.