From: franzi on
On 7 Lug, 17:18, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> franzi <hazz...(a)gmail.com> writes:
> > On 7 Lug, 15:21, franzi <hazz...(a)gmail.com> wrote:
> >> On 7 Lug, 15:16, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> <snip>
> >> >                           I think you want to remove the source file
> >> > when the conversion fails (presumably because un-convertable file are of
> >> > no use to you).  You can do that with:
>
> >> >   textutil -convert html gnu.webarchive || rm gnu.webarchive
>
> >> > (You may not need "rm -f" but let's keep things simple for now.)  The ||
> >> > executes the rm command only if the first command fails.
>
> >> > Your use of {} suggests that you'd like to do this without repeating the
> >> > file name.  For that I'd write a shell function:
>
> >> >   function convert_and_remove
> >> >   {
> >> >       textutil -convert html "$1" || rm "$1"
> >> >   }
> <snip>
> >> > --
> >> > Ben.
>
> It is usual to snip sig blocks, even small ones.
>
> >> Your Intend is right,thank you very much,i will try right now
>
> > I tried your scripts trough cmd line but the rm is not working
>
> "not working" is not very helpful.  What, exactly, did you type?  Are
> there any clues like an error message?  What are the permissions and
> ownership of the file in question[1]?  What is the returned result from
> the textutil command on its own[2]?
>
> [1] What do "ls -l gnu.webarchive" and "whoami" say?  The permissions on
> the directory may also matter ("ls -ld .").
> [2] What does "echo $?" say immediately after "textutil -convert html
> gnu.webarchive"?
>
> --
> Ben.

that's the cmd
textutil -convert html /Volumes/Untitled\ 2/Recu_Leo/Leopard/Users/
hazzhazz/Documents/UNIX\ tips\:\ Productivity\ tips.webarchive "$1" ||
rm "$1"
i got all permission
From: Janis Papanagnou on
On 07/07/10 17:32, franzi wrote:
> On 7 Lug, 17:18, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
[...]
>>
>> "not working" is not very helpful. What, exactly, did you type? Are
>> there any clues like an error message? What are the permissions and
>> ownership of the file in question[1]? What is the returned result from
>> the textutil command on its own[2]?
>>
>> [1] What do "ls -l gnu.webarchive" and "whoami" say? The permissions on
>> the directory may also matter ("ls -ld .").
>> [2] What does "echo $?" say immediately after "textutil -convert html
>> gnu.webarchive"?
>>
>> --
>> Ben.
>
> that's the cmd
> textutil -convert html /Volumes/Untitled\ 2/Recu_Leo/Leopard/Users/
> hazzhazz/Documents/UNIX\ tips\:\ Productivity\ tips.webarchive "$1" ||
> rm "$1"
> i got all permission

You answered just one of the questions. Please read the whole text.
For each question in Ben's posting provide a sensible answer. Then
there will be a chance to help you.

Janis
From: franzi on
> >> the directory may also matter ("ls -ld .").
> >> [2] What does "echo $?" say immediately after "textutil -convert html
> >> gnu.webarchive"?
sh-3.2$ ls -ld
drwx------ 70 hazz staff 2380 Jul 7 17:31 .
sh-3.2$ echo $? textutil -convert html /Volumes/Untitled\ 2/Recu_Leo/
Leopard/Users/hazzhazz/Documents/UNIX\ tips\:\ Productivity\
tips.webarchive "$1"|| rm "$1"
0 textutil -convert html /Volumes/Untitled 2/Recu_Leo/Leopard/Users/
hazzhazz/Documents/UNIX tips: Productivity tips.webarchive
sh-3.2$ ls -la UNIX\ tips\:\ Productivity\ tips.webarchive
-rw-r--r--@ 1 hazz staff 176421 Dec 15 2007 UNIX tips: Productivity
tips.webarchive
sh-3.2$ whoami
hazz

From: Ben Bacarisse on
franzi <hazzino(a)gmail.com> writes:

>> >> the directory may also matter ("ls -ld .").
>> >> [2] What does "echo $?" say immediately after "textutil -convert html
>> >> gnu.webarchive"?
> sh-3.2$ ls -ld
> drwx------ 70 hazz staff 2380 Jul 7 17:31 .
> sh-3.2$ echo $? textutil -convert html /Volumes/Untitled\ 2/Recu_Leo/
> Leopard/Users/hazzhazz/Documents/UNIX\ tips\:\ Productivity\
> tips.webarchive "$1"|| rm "$1"

That's not quote what I meant, but it tells me lots anyway. The $1 only
works if you put the commands in a script or function.

On the command line, your shell may give you a way to refer to a
previously typed file name, but I don't know what shell you are using.
Anyway, I think it is simpler to put the commands into a function. You
can load it every time you start a shell by putting it in one of the
init files for your shell (again I can't say exactly where).

> 0 textutil -convert html /Volumes/Untitled 2/Recu_Leo/Leopard/Users/
> hazzhazz/Documents/UNIX tips: Productivity tips.webarchive
> sh-3.2$ ls -la UNIX\ tips\:\ Productivity\ tips.webarchive
> -rw-r--r--@ 1 hazz staff 176421 Dec 15 2007 UNIX tips: Productivity
> tips.webarchive
> sh-3.2$ whoami
> hazz

I don't know OSX (if the file names are anything to go by I am glad I
don't!) but just be sure that the two names you are using for the file
do indeed refer to the same file.

--
Ben.
From: Barry Margolin on
In article
<0.d6c03d7a7e1bf189c62e.20100707141619BST.87lj9nsa8s.fsf(a)bsb.me.uk>,
Ben Bacarisse <ben.usenet(a)bsb.me.uk> wrote:

> franzi <hazzino(a)gmail.com> writes:
>
> > Hi there, it's been a while that i'm not join'g the group
> > i need some tips..under Leopard is there a way to rm the file not
> > converted
>
> I was puzzled by your use of "not converted"...
>
> > textutil -convert html gnu.webarchive i will have gnu.html
> > i would like to remove the gnu.webarchive can i do like this
> > textutil -convert html gnu.webarchive| rm {} ?????
>
> but working back from this I think you want to remove the source file
> when the conversion fails (presumably because un-convertable file are of
> no use to you). You can do that with:
>
> textutil -convert html gnu.webarchive || rm gnu.webarchive

Shouldn't || be && ? You want to remove the source if the conversion
was successful.

With ||, the second command won't be executed if the first one was
successful.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***