views:

70

answers:

4

This is what I have so far - my dropbox public URL creation script for a directory of public URLs (getdropbox.com - gpl I think). My LIST file was created using ls in the following fashion:

ls -d ~/Dropbox/Public/PUBLICFILES/* > LIST

dropboxpuburl.sh:

for PATH in `cat LIST`
do
   echo $PATH
   dropbox puburl $PATH > ~/URLLIST/$PATH
done

Now this creates a whole series of files - each with the dropbox puburl in them.

The question is: How can I cause this script to redirect all the public links into one text file, each on a new line - perhaps with the name PUBLIC-DIRECTORY-LIST?

A: 

The => creates the files and adds something to the first line. >> appends to it on a new line.

echo txt=>PUBLIC-DIRECTORY-LIST.txt |
echo another text>>PUBLIC-DIRECTORY-LIST.txt
TheBrain
+3  A: 

Is this what you are trying to achieve?

for PATH in `cat LIST`
   do
      echo $PATH
      dropbox puburl $PATH >> filename
   done
Lex
You probably want to delete the file or reset it to empty before that for loop, though.
ndim
This doesn't list the output in the file - only the command - however I have got it working - should I answer my own question?
However my script lists the path then the output.
I edited it to do what you want - looks like probably just a typo copying what you wanted to put in your file. Your self-answer below works too, of course.
Jefromi
Above appends and below clears.
+1  A: 

OK, I've got it working using the suggestions given to me here:

for PATH in `cat LIST`
do
    echo $PATH
    dropbox puburl $PATH
done > PUBLIC-DIRECTORY-LIST

It creates a list of the directories, and below them the public link. Now it is time to prune the directories for a clean text file of links.

A: 

You should use while read with input redirection instead of for with cat filename. Also, in order to avoid variable name conflicts I changed your path variable to lowercase since the shell uses the all-caps one already. It won't affect your interactive shell, but it could affect something in your script.

Also, assuming that you want the lines from your input file to be displayed to the screen as a progress indicator, but not captured in your output file, this echo sends it to stderr.

while read path
do
    echo $path >&2
    dropbox puburl $path
done < LIST > PUBLIC-DIRECTORY-LIST
Dennis Williamson