Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshaiton <shaiton@fedoraproject.org>2011-05-29 11:27:39 (GMT)
committer shaiton <shaiton@fedoraproject.org>2011-05-29 11:27:39 (GMT)
commitb342d723c8263e01c294ac53a03f07c5b99dea9e (patch)
tree6f4e57370fc0661fcb9173c347c54fac23e788f5
parent6119e874485e3fe8745623ef61f43d4885e7307c (diff)
destination path added
-rwxr-xr-xjparser32
1 files changed, 20 insertions, 12 deletions
diff --git a/jparser b/jparser
index 1090e0f..9ff3b73 100755
--- a/jparser
+++ b/jparser
@@ -21,16 +21,18 @@ template_simple=#date${separator}uid${separator}title${separator}buddies
simple_suffix=_simple.txt
user=$USER
format=-c
+dest=./
helpme()
{
- echo "Usage: $0 [output_format] [user_name] [path to $metadata files]."
+ echo "Usage: $0 [output_format] [user_name] [path to $metadata files] [destination path]"
echo " add -h as first arg to print this help"
echo " - file(s) output format could be -s to create a simplified output"
echo " -c to create the complet output (Default)"
echo " -f to create both files"
echo " - if no path specified, the current dir would be used"
echo ' - if no user name is specified, the current $USER would be used' #should check an XO id
+ echo ' - if no detination path is specified, $PWD is used'
exit 0
}
@@ -52,7 +54,6 @@ get_sed()
parse()
{
- out=$2
tmp=$(sed -e 's/": ["]/:/g;s/["], "/#/g;s/^{"//g;s/: ""}//g;s/": /:/g;s/, "/#/g;s/"}//g' $1)
IFS='#' read -ra ADDR <<< "$tmp"
@@ -84,10 +85,10 @@ parse()
esac
if [[ -n "$line_so" ]]; then
- echo `date -d @${timestamp} +%d/%m/%Y`${separator}${uid}${separator}${title}${separator}${buddies} >> ${out}${simple_suffix}
+ echo `date -d @${timestamp} +%d/%m/%Y`${separator}${uid}${separator}${title}${separator}${buddies} >> ${2}${simple_suffix}
fi
if [[ -n "$line" ]]; then
- echo ${activity}${separator}${timestamp}${separator}${uid}${separator}${title}${separator}${title_set}${separator}${buddies} >> $out
+ echo ${activity}${separator}${timestamp}${separator}${uid}${separator}${title}${separator}${title_set}${separator}${buddies} >> $2
fi
exit 0
@@ -97,7 +98,7 @@ parse()
# Start argument processing
#
-if [[ "$#" -gt 4 ]]; then
+if [[ "$#" -gt 5 ]]; then
helpme
fi
@@ -114,9 +115,15 @@ if [[ -n "$1" ]]; then
elif [[ "$1" = "-s" || "$1" = "-f" || "$1" = "-c" ]]; then # Format output provided as arg?
format=$1
if [[ -n "$2" ]]; then # User provided as arg?
- user=$2
- if [ $# -lt 4 ]; then # Path provided as arg?
- path=$3
+ user=$2
+ if [[ -n "$3" ]]; then # Path provided as arg?
+ path=$3
+ if [[ -n "$4" ]]; then
+ dest=${4}/
+ if [ ! -d "$dest" ]; then
+ mkdir $dest
+ fi
+ fi
fi
elif [ -e /ofw/serial-number ]; then # if we are from an XO, grad its serial
user=`cat /ofw/serial-number`
@@ -131,14 +138,15 @@ fi
# Let's start parsing
#
-out=${user}_`date +%F`.txt
+out=${dest}${user}_`date +%F`.txt
+out_simple=${out}${simple_suffix}
# create template files
if [[ "$1" = "-s" || "$1" = "-f" ]]; then
- if [ ! -f ${out}${simple_suffix} ]; then
- echo $template_simple > ${out}${simple_suffix}
+ if [ ! -f $out_simple ]; then
+ echo $template_simple > $out_simple
else
- echo >> ${out}${simple_suffix}
+ echo >> $out_simple
fi
elif [[ "$1" = "-c" || "$1" = "-f" ]]; then
if [ ! -f $out ]; then