SCIENTIFIC-LINUX-USERS Archives

March 2015

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
ToddAndMargo <[log in to unmask]>
Reply To:
ToddAndMargo <[log in to unmask]>
Date:
Mon, 2 Mar 2015 13:20:43 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (107 lines)
On 03/02/2015 01:00 PM, Chris Schanzle wrote:
> On 02/27/2015 08:04 PM, ToddAndMargo wrote:
>> On 02/27/2015 04:38 PM, ToddAndMargo wrote:
>>> Hi All,
>>>
>>> I am trying to get PDF Studio to open multiple pdf's
>>> from a script.  But PDF Studio will only accept one file
>>> name on its command line.  But you can have multiple
>>> PDF Studios open, so I tried
>>>
>>> find  -maxdepth 1 -iname \*.pdf -exec /opt/pdfstudio9/pdfstudio9 {} \;
>>>
>>> But you have to close the first instance to get the second
>>> to open, etc..
>>>
>>> I have tried adding "&" to the end, but no syntax joy.
>>>
>>> How to I get "-exec" to run and release, so "find" can go
>>> on to the next instance?
>>>
>>> Many thanks,
>>> -T
>>>
>>
>>
>> This works, but Gee Wiz!
>>
>> #!/bin/bash
>>
>> # Open all (lower case) pdf documents in this directory
>> # /usr/bin/acroread *.pdf
>> #/opt/pdfstudio9/pdfstudio9 *.pdf
>>
>> Tmp="Open.All.PDFs.tmp.sh"
>>
>> if [ -f "${Tmp}" ]; then rm "${Tmp}"; fi
>> echo "#!/bin/bash" > "${Tmp}"
>> echo "" >> "${Tmp}"
>>
>> find -maxdepth 1 -iname \*.pdf -exec echo "/opt/pdfstudio9/pdfstudio9 {} &" \; >> "${Tmp}"
>> chmod 755 "${Tmp}"
>> eval "${Tmp}"
>> rm "${Tmp}"
>>
>>
>>
> you don't need any of those braces (to separate from other surrounding text) or quotes (you know it doesn't have spaces) when YOU define the variable.
>
> also, what if Tmp is something other than a plain file to something else?  you get hosed.  Use -e rather than -f.  Use mktemp!
>
>
> Tmp=Open.All.PDFs.tmp.sh
> [ -e $Tmp ] && rm ${Tmp}
> echo "#!/bin/bash" > $Tmp
> echo  >> $Tmp
>
> find -maxdepth 1 -iname \*.pdf -exec echo "/opt/pdfstudio9/pdfstudio9 {} &" \; >> $Tmp
> # notneeded chmod 755 $Tmp
> bash $Tmp
> rm $Tmp
> ------------------------
>
> Perhaps this would work as well, not suggested yet...
>
> find -maxdepth 1 -iname \*.pdf -exec bash -c "/opt/pdfstudio9/pdfstudio9 {} &" \;
>
> I tested the above  by making 'myls' script, which contained:
>
> echo myls[$$]: "$@"
> ls -l "$@"
> sleep 5
> echo done[$$]
>
> Note how it shows the pid ($$), shows the args to ensure only one arg was received, runs a real 'ls', then sleeps, then echos done with the pid again...
>
> find * -exec bash -c "./myls {} &" \;
>
> Seems to work as expected.

Hi Chris,

I use the braces on purpose, even thought the are not needed, to
disciple my self to use them when required.  For instance:

NewFileName2="$(echo ${NewFileName} | sed -e 
"s/\_..*${BaseTag}/_${LastestRevDashes}_${BaseTag}/")"

The braces habit keeps me out of trouble.

I am going to have to look closely at mktemp, as I have always
just created my own in the past.

"Tmp" is a text file I use to create a dynamic bash script.  You
note that I clean up after myself when I finish.

find * -exec bash -c "./myls {} &" \;
Works because "ls" releases after each call to it.  PDF Studio
waits for you to manually exit.

I also could not get the syntax right for using "&", but
I never tried putting quotes around the entire --exec
command.

Thank you!

-T

ATOM RSS1 RSS2