Re: removing a pesky file

2009-05-15 Thread Jordi Beltran Creix
2009/5/15 Ryan Flannery ryan.flann...@gmail.com:
 tarski rm `ls | grep E`
 ~,u?} w=R1 T)U7r 5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
 B  B  B  B  B  B  B  B  B Ec?J9 K%Mx/!...@s S,W7g?5
 0,z: No such file or directory B  B  B  B  B  B 
M}OWDt?Yw?rB~[*6t?0h|7aBz_
 tarski

True, I had checked it using the shell to recreate your file. I get that now.
However, rm *EV* does delete it without complaining at all(rm -i will
print the name and thus fail), still it doesn't seem like you had
tried everything...



Re: removing a pesky file

2009-05-15 Thread Jan Stary
On May 14 20:47:46, Ryan Flannery wrote:
 I've been in similar situations countless times, but this one is
 throwing me a for a loop.
 
 I have a file that I'm trying to remove with non-printable characters
 in the name.  Additionally, some of the characters appear to be
 backspace/delete/etc.
 
 All my normal tricks with rm(1) fail.
 Using vim on the directory to try and delete the entry fails.
 
 I can get the inode of the file with ls(1)

man fsdb, clear the inode with clri.

Jan



removing a pesky file

2009-05-14 Thread Ryan Flannery
I've been in similar situations countless times, but this one is
throwing me a for a loop.

I have a file that I'm trying to remove with non-printable characters
in the name.  Additionally, some of the characters appear to be
backspace/delete/etc.

All my normal tricks with rm(1) fail.
Using vim on the directory to try and delete the entry fails.

I can get the inode of the file with ls(1), and used that to write the
following program which I thought would help, but sadly it too fails.

#include stdio.h
#include sys/types.h
#include dirent.h
#include err.h
#include unistd.h

int main(void)
{

   /* open directory */
   DIR *usr;
   if ((usr = opendir(/usr)) == NULL)
  err(1, failed to opendir);


   /* read through until we find the evil one... */
   struct dirent *entry;
   while ((entry = readdir(usr)) != NULL)
   {
  /* check against known evil inode */
  if (entry-d_fileno == 1065344)
  {
 /* got it */
 printf(found file...name length is: %d\n, entry-d_namlen);

 /* build filename as a char* */
 uint8_t i;
 for (i = 0; i  entry-d_namlen; i++)
printf(%d , entry-d_name[i]);


 /* cross fingers */
 printf(\n\nattempting to unlink...\n);
 if (unlink(entry-d_name)  0)
err(1, failure, crack 'nother beer);
  }
   }

   closedir(usr);

   return 0;
}


the program outputs the following:

found file...name length is: 194
-104 38 13 40 -22 101 -13 -4 -68 -107 69 86 49 -92 69 37 -90 -95 -52
20 27 -104 -24 -60 82 -49 46 -50 79 -70 23 -30 66 -29 56 89 29 -100
-127 59 83 -115 28 26 -121 30 81 -45 67 -53 -100 -76 103 15 109 -88 17
95 69 -102 87 -35 -41 -83 -13 -18 9 62 76 44 -52 99 33 -5 39 79 -100
49 -111 6 -64 -94 -97 19 -10 34 104 -87 100 28 125 4 -52 -101 84 -85
85 92 13 -2 -84 -11 63 125 -1 119 -67 82 27 96 -113 -79 -1 84 -87 -43
55 -14 -1 53 -124 69 -29 -65 74 27 96 -113 -71 -1 -111 75 -91 -51 -8
-81 33 -120 -58 127 85 54 -64 30 115 -1 83 44 -41 55 -25 -65 53 -124
-51 -3 -49 -41 29 -60 -12 -65 26 27 96 -39 -9 63 114 66 -2 91 -86 -105
54 -12 -65 -122 -80 104 -4 55 60 -31 -21 8 66 -6 95 -111 13 -80 44 -6

attempting to unlink...
a.out: failure, crack 'nother beer: No such file or directory


Questions:
1.  Any whacks of a clue-stick would be greatly appreciated.
2.  When I printf dirent struct's d_namlen field, is says 302...
grep'ing /usr/include, isn't this 255?  How can this happen?
3.  Passing the d_name field directly to unlink(2)... this should
work, correct?  (I tried this with a sample setup elsewhere and it
did).  Any thoughts why this would fail?

To those who are curious, the file was created when I went to unpack a
ports.tar.gz and forgot the 'z' switch... d'oh.

Anyway, I could try deleting the parent directory, but it's /usr.

-Ryan



Re: removing a pesky file

2009-05-14 Thread Philip Guenther
On Thu, May 14, 2009 at 5:47 PM, Ryan Flannery ryan.flann...@gmail.com
wrote:
...
 I can get the inode of the file with ls(1), and used that to write the
 following program which I thought would help, but sadly it too fails.
...
   /* open directory */
   DIR *usr;
   if ((usr = opendir(/usr)) == NULL)
  err(1, failed to opendir);
...
 /* cross fingers */
 printf(\n\nattempting to unlink...\n);
 if (unlink(entry-d_name)  0)
err(1, failure, crack 'nother beer);
...
 Questions:
 1.  Any whacks of a clue-stick would be greatly appreciated.

So you listed /usr and found the problem name and then you try to
remove that file from your current directory.  Is your current
directory /usr ?


 2.  When I printf dirent struct's d_namlen field, is says 302...
 grep'ing /usr/include, isn't this 255?  How can this happen?

Hmm, what type of filesystem is /usr ?


 3.  Passing the d_name field directly to unlink(2)... this should
 work, correct?  (I tried this with a sample setup elsewhere and it
 did).  Any thoughts why this would fail?

Yes, modulus current vs listed directory issues.


Philip Guenther



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Thu, May 14, 2009 at 9:10 PM, Philip Guenther guent...@gmail.com wrote:
 On Thu, May 14, 2009 at 5:47 PM, Ryan Flannery ryan.flann...@gmail.com
wrote:
 ...
 I can get the inode of the file with ls(1), and used that to write the
 following program which I thought would help, but sadly it too fails.
 ...
   /* open directory */
   DIR *usr;
   if ((usr = opendir(/usr)) == NULL)
  err(1, failed to opendir);
 ...
 /* cross fingers */
 printf(\n\nattempting to unlink...\n);
 if (unlink(entry-d_name)  0)
err(1, failure, crack 'nother beer);
 ...
 Questions:
 1.  Any whacks of a clue-stick would be greatly appreciated.

 So you listed /usr and found the problem name and then you try to
 remove that file from your current directory.  Is your current
 directory /usr ?

Gah!  That was it.
This is what happens when you decide to drink till ya fix it

Many Thanks
-Ryan



Re: removing a pesky file

2009-05-14 Thread Matthew Clarke
Thu, May 14, 2009 at 08:47:46PM -0400, Ryan Flannery may have written:

 I've been in similar situations countless times, but this one is
 throwing me a for a loop.
 
 I have a file that I'm trying to remove with non-printable characters
 in the name.  Additionally, some of the characters appear to be
 backspace/delete/etc.
 
 All my normal tricks with rm(1) fail.

[ snip ]

Even

# pwd
/usr
# rm -i -- ??*

followed by very careful use of the y, n and Enter keys?

Matt.
-- 
With trembling hands he unfurled the ancient cracked parchment, this was
the place, it had to be. Uncertainly he began to mumble the chant rdbms,
sql , third normal formal form, java,  table, scalable. Something moved..
From outside they heard a scream and a thud. The sales department had awoken
-- .sig by Alan Cox



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Thu, May 14, 2009 at 9:28 PM, Matthew Clarke cla...@telus.net wrote:
 Thu, May 14, 2009 at 08:47:46PM -0400, Ryan Flannery may have written:

 I've been in similar situations countless times, but this one is
 throwing me a for a loop.

 I have a file that I'm trying to remove with non-printable characters
 in the name.  Additionally, some of the characters appear to be
 backspace/delete/etc.

 All my normal tricks with rm(1) fail.

 [ snip ]

 Even

# pwd
/usr
# rm -i -- ??*

 followed by very careful use of the y, n and Enter keys?


Nope.  Tried that, it failed too.



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Thu, May 14, 2009 at 9:48 PM, Ryan Flannery ryan.flann...@gmail.com
wrote:
 On Thu, May 14, 2009 at 9:28 PM, Matthew Clarke cla...@telus.net wrote:
 Thu, May 14, 2009 at 08:47:46PM -0400, Ryan Flannery may have written:

 I've been in similar situations countless times, but this one is
 throwing me a for a loop.

 I have a file that I'm trying to remove with non-printable characters
 in the name.  Additionally, some of the characters appear to be
 backspace/delete/etc.

 All my normal tricks with rm(1) fail.

 [ snip ]

 Even

# pwd
/usr
# rm -i -- ??*

 followed by very careful use of the y, n and Enter keys?


 Nope.  Tried that, it failed too.

Sorry, I meant to expand upon this further...
with `rm -i`, when it came to the appropriate file, the output was
horribly mucked-up (see below), and even hitting 'y + Enter' for it
failed.

r...@tarski rm -ri /usr/*
remove usr/X11R6? n
remove usr/bin? n
remove usr/games? n
remove usr/include? n
remove usr/lib? n
remove usr/libdata? n
remove usr/libexec? n
remove usr/lkm? n
remove usr/local? n
remove usr/mdec? n
remove usr/obj? n
remove usr/ports? n
remove usr/ports.tar.gz? n
remove usr/sbin? n
remove usr/share? n
~,u?}w=R1T)U7r5  +U\
remove usr/xobj? nEc?J9K%Mx/!...@ss,W7g?5Lc!{'O1@
0,z? ^[[?1;2cy M}OWDt?Yw?rB~[*6t?0h|7aBz_


the 'y' I entered is on that last line, before the big 'white space'
and the rest of the text.

the full output of `ls` in /usr/ was
r...@tarski ls usr/
X11R6
bin
games
include
lib
libdata
libexec
lkm
local
mdec
obj
ports
ports-old
ports-old2
ports.tar.gz
sbin
share
src
xobj
??(jes|?EV1$E%!L???hDRO.NO:?bBc8Y???;S?QSCK?4g?m(?_E?W]W-sn?L,Lc!{'O?
1??@??vh)d?}?L?T+U\?~,u?}?w=R?`?1?T)U7r?5?Ec?J?`?9??K%Mx/!?f...@?s?s,W7g?5?
M}OW?Dt???`Yw?rB~[*?6t??0h|7ak?Bz_??0,z



Re: removing a pesky file

2009-05-14 Thread Jordi Beltran Creix
rm `ls | grep E` would delete that file leaving others alone.

Regards,



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Thu, May 14, 2009 at 10:53 PM, Jordi Beltran Creix
jbcreix.m...@gmail.com wrote:
 rm `ls | grep E` would delete that file leaving others alone.

 Regards,


Just for the list...
I had tried that incantation, and others involving grep, and they all failed.

Output (I just reproduced the file) from your example is:

tarski wget ftp://rt.fm/pub/OpenBSD/snapshots/ports.tar.gz
...(wget output)...
tarski  tar xf ports.tar.gz
...(tar output, lots-o-errors, obviously)...

now the file exists with the mucked-up name (see previous post for how
ls(1) displays it)
and here's what happens when I use the rm `ls | grep E` you
suggested (and I tried earlier... again with many variations)

tarski rm `ls | grep E`
~,u?}w=R1T)U7r5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
  Ec?J9K%Mx/!...@ss,W7g?5
0,z: No such file or directory M}OWDt?Yw?rB~[*6t?0h|7aBz_
tarski



Re: removing a pesky file

2009-05-14 Thread Tony Abernethy
Ryan Flannery wrote:
 On Thu, May 14, 2009 at 10:53 PM, Jordi Beltran Creix
 jbcreix.m...@gmail.com wrote:
  rm `ls | grep E` would delete that file leaving others alone.
 
  Regards,
 

 Just for the list...
 I had tried that incantation, and others involving grep, and
 they all failed.

 Output (I just reproduced the file) from your example is:

 tarski wget ftp://rt.fm/pub/OpenBSD/snapshots/ports.tar.gz
 ...(wget output)...
 tarski  tar xf ports.tar.gz
 ...(tar output, lots-o-errors, obviously)...

 now the file exists with the mucked-up name (see previous post for how
 ls(1) displays it)
 and here's what happens when I use the rm `ls | grep E` you
 suggested (and I tried earlier... again with many variations)

 tarski rm `ls | grep E`
 ~,u?}w=R1T)U7r5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
   Ec?J9K%Mx/!...@ss,W7g?5
 0,z: No such file or directory M}OWDt?Yw?rB~[*6t?0h|7aBz_
 tarski


You might try something like
mkdir /usr-new
mv /usr/[a-z0-9A-Z]* /usr-new
ls -l /usr

AFTER EVERYTHING mentionaable has been moved
rm -rf /usr
mv /usr-new /usr



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Thu, May 14, 2009 at 11:42 PM, Tony Abernethy t...@servacorp.com wrote:
 Ryan Flannery wrote:
 On Thu, May 14, 2009 at 10:53 PM, Jordi Beltran Creix
 jbcreix.m...@gmail.com wrote:
  rm `ls | grep E` would delete that file leaving others alone.
 
  Regards,
 

 Just for the list...
 I had tried that incantation, and others involving grep, and
 they all failed.

 Output (I just reproduced the file) from your example is:

 tarski wget ftp://rt.fm/pub/OpenBSD/snapshots/ports.tar.gz
 ...(wget output)...
 tarski  tar xf ports.tar.gz
 ...(tar output, lots-o-errors, obviously)...

 now the file exists with the mucked-up name (see previous post for how
 ls(1) displays it)
 and here's what happens when I use the rm `ls | grep E` you
 suggested (and I tried earlier... again with many variations)

 tarski rm `ls | grep E`
 ~,u?} w=R1 T)U7r 5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
   Ec?J9 K%Mx/!...@s S,W7g?5
 0,z: No such file or directory M}OWDt?Yw?rB~[*6t?0h|7aBz_
 tarski


 You might try something like
 mkdir /usr-new
 mv /usr/[a-z0-9A-Z]* /usr-new
 ls -l /usr

 AFTER EVERYTHING mentionaable has been moved
 rm -rf /usr
 mv /usr-new /usr

I thought about this... moving everything out of /usr so I could just
delete the mischievous file's parent directory, which would certainly
have worked.

The /usr slice is quite hefty, and the time to move everything to a
new partition would have been a while... I kept trying to find another
way around this (which probably took way longer than it would have to
just copy everything out of /usr to a new partition  :)



Re: removing a pesky file

2009-05-14 Thread Ryan Flannery
On Fri, May 15, 2009 at 12:07 AM, Chris Kuethe chris.kue...@gmail.com wrote:
 cd /usr
 mkdir .save
 mv [A-Za-z]* .save
 rm *
 mv .save/* .



Son of a #...@!^%

Yes, that would have been *far* simpler/easier/quicker, and would have worked.
*That's* the clue-stick I was looking for.

Many Thanks



Re: removing a pesky file

2009-05-14 Thread Tony Abernethy
Ryan Flannery wrote:
 On Thu, May 14, 2009 at 11:42 PM, Tony Abernethy 
 t...@servacorp.com wrote:
  Ryan Flannery wrote:
  On Thu, May 14, 2009 at 10:53 PM, Jordi Beltran Creix
  jbcreix.m...@gmail.com wrote:
   rm `ls | grep E` would delete that file leaving others alone.
  
   Regards,
  
 
  Just for the list...
  I had tried that incantation, and others involving grep, and
  they all failed.
 
  Output (I just reproduced the file) from your example is:
 
  tarski wget ftp://rt.fm/pub/OpenBSD/snapshots/ports.tar.gz
  ...(wget output)...
  tarski  tar xf ports.tar.gz
  ...(tar output, lots-o-errors, obviously)...
 
  now the file exists with the mucked-up name (see previous 
 post for how
  ls(1) displays it)
  and here's what happens when I use the rm `ls | grep E` you
  suggested (and I tried earlier... again with many variations)
 
  tarski rm `ls | grep E`
  ~,u?} w=R1 T)U7r 5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
Ec?J9 K%Mx/!...@s S,W7g?5
  0,z: No such file or directory 
 M}OWDt?Yw?rB~[*6t?0h|7aBz_
  tarski
 
 
  You might try something like
  mkdir /usr-new
  mv /usr/[a-z0-9A-Z]* /usr-new
  ls -l /usr
 
  AFTER EVERYTHING mentionaable has been moved
  rm -rf /usr
  mv /usr-new /usr
 
 I thought about this... moving everything out of /usr so I could just
 delete the mischievous file's parent directory, which would certainly
 have worked.
 
 The /usr slice is quite hefty, and the time to move everything to a
 new partition would have been a while... I kept trying to find another
 way around this (which probably took way longer than it would have to
 just copy everything out of /usr to a new partition  :)
 
Out of curiosits, what does 
ls -il /usr/*w=R1*
ls -il /usr/[^a-zA-Z0-9]*
produce?

You might get it with a pattern that gets nothing of value.
rm -f /usr/[^a-zA-Z0-9]*



Re: removing a pesky file

2009-05-14 Thread Navan Carson

On May 14, 2009, at 9:15 PM, Ryan Flannery wrote:


On Thu, May 14, 2009 at 10:53 PM, Jordi Beltran Creix
jbcreix.m...@gmail.com wrote:

rm `ls | grep E` would delete that file leaving others alone.

Regards,



Just for the list...
I had tried that incantation, and others involving grep, and they  
all failed.


Output (I just reproduced the file) from your example is:

tarski wget ftp://rt.fm/pub/OpenBSD/snapshots/ports.tar.gz
...(wget output)...
tarski  tar xf ports.tar.gz
...(tar output, lots-o-errors, obviously)...

now the file exists with the mucked-up name (see previous post for how
ls(1) displays it)
and here's what happens when I use the rm `ls | grep E` you
suggested (and I tried earlier... again with many variations)

tarski rm `ls | grep E`
~,u?}w=R1T)U7r5\4gm(_EW]W-sn^[[?1;2c: No such file or directory
 Ec?J9K%Mx/!...@ss,W7g?5
0,z: No such file or directory M}OWDt?Yw?rB~[*6t?0h|7aBz_
tarski




I tried your example. The oddly named entry is a directory.
rm -i * does not work, but rm -ri * does let me remove it.



Re: removing a pesky file

2009-05-14 Thread Prabhu Gurumurthy
why can't you use ls -i, find the inode, and do find . -inum INODENUM   
-exec rm {} \;


is it a list of file that you want to remove put all the files in a  
text file and do a for loop.


HTH!
Prabhu
-


On May 14, 2009, at 5:47 PM, Ryan Flannery wrote:


I've been in similar situations countless times, but this one is
throwing me a for a loop.

I have a file that I'm trying to remove with non-printable characters
in the name.  Additionally, some of the characters appear to be
backspace/delete/etc.

All my normal tricks with rm(1) fail.
Using vim on the directory to try and delete the entry fails.

I can get the inode of the file with ls(1), and used that to write the
following program which I thought would help, but sadly it too fails.

#include stdio.h
#include sys/types.h
#include dirent.h
#include err.h
#include unistd.h

int main(void)
{

  /* open directory */
  DIR *usr;
  if ((usr = opendir(/usr)) == NULL)
 err(1, failed to opendir);


  /* read through until we find the evil one... */
  struct dirent *entry;
  while ((entry = readdir(usr)) != NULL)
  {
 /* check against known evil inode */
 if (entry-d_fileno == 1065344)
 {
/* got it */
printf(found file...name length is: %d\n, entry-d_namlen);

/* build filename as a char* */
uint8_t i;
for (i = 0; i  entry-d_namlen; i++)
   printf(%d , entry-d_name[i]);


/* cross fingers */
printf(\n\nattempting to unlink...\n);
if (unlink(entry-d_name)  0)
   err(1, failure, crack 'nother beer);
 }
  }

  closedir(usr);

  return 0;
}


the program outputs the following:

found file...name length is: 194
-104 38 13 40 -22 101 -13 -4 -68 -107 69 86 49 -92 69 37 -90 -95 -52
20 27 -104 -24 -60 82 -49 46 -50 79 -70 23 -30 66 -29 56 89 29 -100
-127 59 83 -115 28 26 -121 30 81 -45 67 -53 -100 -76 103 15 109 -88 17
95 69 -102 87 -35 -41 -83 -13 -18 9 62 76 44 -52 99 33 -5 39 79 -100
49 -111 6 -64 -94 -97 19 -10 34 104 -87 100 28 125 4 -52 -101 84 -85
85 92 13 -2 -84 -11 63 125 -1 119 -67 82 27 96 -113 -79 -1 84 -87 -43
55 -14 -1 53 -124 69 -29 -65 74 27 96 -113 -71 -1 -111 75 -91 -51 -8
-81 33 -120 -58 127 85 54 -64 30 115 -1 83 44 -41 55 -25 -65 53 -124
-51 -3 -49 -41 29 -60 -12 -65 26 27 96 -39 -9 63 114 66 -2 91 -86 -105
54 -12 -65 -122 -80 104 -4 55 60 -31 -21 8 66 -6 95 -111 13 -80 44 -6

attempting to unlink...
a.out: failure, crack 'nother beer: No such file or directory


Questions:
1.  Any whacks of a clue-stick would be greatly appreciated.
2.  When I printf dirent struct's d_namlen field, is says 302...
grep'ing /usr/include, isn't this 255?  How can this happen?
3.  Passing the d_name field directly to unlink(2)... this should
work, correct?  (I tried this with a sample setup elsewhere and it
did).  Any thoughts why this would fail?

To those who are curious, the file was created when I went to unpack a
ports.tar.gz and forgot the 'z' switch... d'oh.

Anyway, I could try deleting the parent directory, but it's /usr.

-Ryan