rm + stdin - Redhat

This is a discussion on rm + stdin - Redhat ; I am trying to use rm within an app to manage removing some files. I end up with the following errors: /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/ *.DBF': No such file or directory /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/ *.dbf': No such file or ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: rm + stdin

  1. rm + stdin

    I am trying to use rm within an app to manage removing some files. I
    end up with the following errors:

    /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    *.DBF': No such file or directory
    /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    *.dbf': No such file or directory
    /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    *.zip': No such file or directory
    /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    *.ZIP': No such file or director

    I know that the files are most definitely there with one of those
    suffixes but am not sure why this happens. Any suggestions?

  2. Re: rm + stdin

    On Jul 5, 8:31*pm, Nico Kadel-Garcia wrote:
    > Steffan wrote:
    > > I am trying to use rm within an app to manage removing some files. I
    > > end up with the following errors:

    >
    > > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > > *.DBF': No such file or directory
    > > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > > *.dbf': No such file or directory
    > > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > > *.zip': No such file or directory
    > > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > > *.ZIP': No such file or director

    >
    > > I know that the files are most definitely there with one of those
    > > suffixes but am not sure why this happens. Any suggestions?

    >
    > It's probably not there, after all. Why not put in a debugging statement to
    > verify that it is present or not? And use 'rm -f' in case the file isn't there
    > at that moment?


    I know the file is there. The path is stored in a variable and reused
    all over without fail except when we get to this point. I wonder if
    this is more of a limitation of rm being launched via a process rather
    than a shell.

  3. Re: rm + stdin

    Steffan wrote:
    > I am trying to use rm within an app to manage removing some files. I
    > end up with the following errors:
    >
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.DBF': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.dbf': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.zip': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.ZIP': No such file or director
    >
    > I know that the files are most definitely there with one of those
    > suffixes but am not sure why this happens. Any suggestions?


    It's probably not there, after all. Why not put in a debugging statement to
    verify that it is present or not? And use 'rm -f' in case the file isn't there
    at that moment?

  4. Re: rm + stdin

    Steffan wrote:
    > On Jul 5, 8:31 pm, Nico Kadel-Garcia wrote:
    >> Steffan wrote:
    >>> I am trying to use rm within an app to manage removing some files. I
    >>> end up with the following errors:
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.DBF': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.dbf': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.zip': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.ZIP': No such file or director
    >>> I know that the files are most definitely there with one of those
    >>> suffixes but am not sure why this happens. Any suggestions?

    >> It's probably not there, after all. Why not put in a debugging statement to
    >> verify that it is present or not? And use 'rm -f' in case the file isn't there
    >> at that moment?

    >
    > I know the file is there. The path is stored in a variable and reused
    > all over without fail except when we get to this point. I wonder if
    > this is more of a limitation of rm being launched via a process rather
    > than a shell.



    Thmm. Let's think about this. That is *NOT* a file. It is a regexp that is
    supposed to find files in that directory that match that regexp. Just because
    you use it elsewhere, doesn't mean there are any such files there: the output
    of a command like 'ls', with that argument, will output nothing to stdout if
    there are no such files, and simply report exactly that sort of error if to
    stderr.

    OK, with me so far?

    So you need to report whether such files actually exist. An 'ls' with output,
    run just before the 'rm' command, might be helpful. And further analysis
    depends on exactly what your application is doing.

  5. Re: rm + stdin

    On Jul 6, 12:13*am, Nico Kadel-Garcia wrote:
    > Steffan wrote:
    > > On Jul 5, 8:31 pm, Nico Kadel-Garcia wrote:
    > >> Steffan wrote:
    > >>> I am trying to use rm within an app to manage removing some files. I
    > >>> end up with the following errors:
    > >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > >>> *.DBF': No such file or directory
    > >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > >>> *.dbf': No such file or directory
    > >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > >>> *.zip': No such file or directory
    > >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > >>> *.ZIP': No such file or director
    > >>> I know that the files are most definitely there with one of those
    > >>> suffixes but am not sure why this happens. Any suggestions?
    > >> It's probably not there, after all. Why not put in a debugging statement to
    > >> verify that it is present or not? And use 'rm -f' in case the file isn't there
    > >> at that moment?

    >
    > > I know the file is there. The path is stored in a variable and reused
    > > all over without fail except when we get to this point. I wonder if
    > > this is more of a limitation of rm being launched via a process rather
    > > than a shell.

    >
    > Thmm. Let's think about this. That is *NOT* a file. It is a regexp that is
    > supposed to find files in that directory that match that regexp. Just because
    > you use it elsewhere, doesn't mean there are any such files there: the output
    > of a command like 'ls', with that argument, will output nothing to stdoutif
    > there are no such files, and simply report exactly that sort of error if to
    > stderr.
    >
    > OK, with me so far?
    >
    > So you need to report whether such files actually exist. An 'ls' with output,
    > run just before the 'rm' command, might be helpful. And further analysis
    > depends on exactly what your application is doing.


    Well, it appears to be an issue with using rm within a process. I
    opened a shell rather than a process and executed the same rm
    statement and it worked. So, I guess in this case I may have to just
    stick with the shell as it seems faster in my case.

  6. Re: rm + stdin

    Steffan wrote:
    > On Jul 6, 12:13 am, Nico Kadel-Garcia wrote:
    >
    >>Steffan wrote:
    >>
    >>>On Jul 5, 8:31 pm, Nico Kadel-Garcia wrote:
    >>>
    >>>>Steffan wrote:
    >>>>
    >>>>>I am trying to use rm within an app to manage removing some files. I
    >>>>>end up with the following errors:
    >>>>>/bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>>>>*.DBF': No such file or directory
    >>>>>/bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>>>>*.dbf': No such file or directory
    >>>>>/bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>>>>*.zip': No such file or directory
    >>>>>/bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>>>>*.ZIP': No such file or director
    >>>>>I know that the files are most definitely there with one of those
    >>>>>suffixes but am not sure why this happens. Any suggestions?
    >>>>
    >>>>It's probably not there, after all. Why not put in a debugging statement to
    >>>>verify that it is present or not? And use 'rm -f' in case the file isn't there
    >>>>at that moment?

    >>
    >>>I know the file is there. The path is stored in a variable and reused
    >>>all over without fail except when we get to this point. I wonder if
    >>>this is more of a limitation of rm being launched via a process rather
    >>>than a shell.

    >>
    >>Thmm. Let's think about this. That is *NOT* a file. It is a regexp that is
    >>supposed to find files in that directory that match that regexp. Just because
    >>you use it elsewhere, doesn't mean there are any such files there: the output
    >>of a command like 'ls', with that argument, will output nothing to stdout if
    >>there are no such files, and simply report exactly that sort of error if to
    >>stderr.
    >>
    >>OK, with me so far?
    >>
    >>So you need to report whether such files actually exist. An 'ls' with output,
    >>run just before the 'rm' command, might be helpful. And further analysis
    >>depends on exactly what your application is doing.

    >
    >
    > Well, it appears to be an issue with using rm within a process. I
    > opened a shell rather than a process and executed the same rm
    > statement and it worked. So, I guess in this case I may have to just
    > stick with the shell as it seems faster in my case.

    Stefan,


    Do you run the shell and the process under the same user?


    Kind regards,


    Jan Gerrit Kootstra

  7. Re: rm + stdin

    What language are you using? For example in C, you could:
    opendir();
    readdir();
    unlink();
    closedir();

    On Jul 5, 6:02*pm, Steffan wrote:
    > I am trying to use rm within an app to manage removing some files. I
    > end up with the following errors:
    >
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.DBF': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.dbf': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.zip': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.ZIP': No such file or director
    >
    > I know that the files are most definitely there with one of those
    > suffixes but am not sure why this happens. Any suggestions?



  8. Re: rm + stdin

    Steffan writes:

    > Well, it appears to be an issue with using rm within a process. I
    > opened a shell rather than a process and executed the same rm
    > statement and it worked. So, I guess in this case I may have to just
    > stick with the shell as it seems faster in my case.


    Your subprocess is not doing file globbing. Which "app" are you talking
    about?

    -- HASM



  9. Re: rm + stdin

    Rajendra Singh wrote:
    > What language are you using? For example in C, you could:
    > opendir();
    > readdir();
    > unlink();
    > closedir();
    >
    > On Jul 5, 6:02 pm, Steffan wrote:
    >> I am trying to use rm within an app to manage removing some files. I
    >> end up with the following errors:
    >>
    >> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >> *.DBF': No such file or directory
    >> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >> *.dbf': No such file or directory
    >> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >> *.zip': No such file or directory
    >> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >> *.ZIP': No such file or director
    >>
    >> I know that the files are most definitely there with one of those
    >> suffixes but am not sure why this happens. Any suggestions?

    >


    What? This won't work with C at all! It's not a directory, it's all files in
    the directory that end with the suffix *.DBF or *.dbf.

    This is not a RedHat specific issue, this is an issue of whatever language the
    software is written in.

  10. Re: rm + stdin

    Nico Kadel-Garcia wrote:
    > Rajendra Singh wrote:
    >> What language are you using? For example in C, you could:
    >> opendir();
    >> readdir();
    >> unlink();
    >> closedir();
    >>
    >> On Jul 5, 6:02 pm, Steffan wrote:
    >>> I am trying to use rm within an app to manage removing some files. I
    >>> end up with the following errors:
    >>>
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.DBF': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.dbf': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.zip': No such file or directory
    >>> /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    >>> *.ZIP': No such file or director
    >>>
    >>> I know that the files are most definitely there with one of those
    >>> suffixes but am not sure why this happens. Any suggestions?

    >>

    >
    > What? This won't work with C at all! It's not a directory, it's all
    > files in the directory that end with the suffix *.DBF or *.dbf.
    >
    > This is not a RedHat specific issue, this is an issue of whatever
    > language the software is written in.


    Rajenda sent me a private email, which I'm not sure he sent to the group as
    well, so I'm following up here. Rajenda wrote: "Yes it will work with C.
    readdir reads the contents of a directory."

    I'm reading the original request above. That is for 'all files in the
    directory that end in {dbf,DBF,zip,ZIP}'. That's not 'all files in the
    directory, so no, it won't work. without cleverness to avoid other files. That
    takes some regexp handling, which is where our hero may have been having
    trouble in the first place.

    I'll revoice my concern that his 'rm' statement is happening at a time when
    there are, in fact, no such files in place. It's easy with any kind of
    asynchronous operations, such as clearing the debris away from another
    program, to accidentally run the 'rm' when the files aren't actually generated
    yet.

  11. Re: rm + stdin

    Steffan wrote:
    > I am trying to use rm within an app to manage removing some files. I
    > end up with the following errors:
    >
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.DBF': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.dbf': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.zip': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.ZIP': No such file or director
    >
    > I know that the files are most definitely there with one of those
    > suffixes but am not sure why this happens. Any suggestions?


    Looks like your '*' is not expanding so it is looking to delete a
    file(s) named specifically *.dbf etc... change or remove the quotes to
    get the '*' expanding as you want.

    JR.


    --

    Bill will have to take Linux from my cold, dead flippers.

    -Tux.

  12. Re: rm + stdin

    Dear Steffan,

    Steffan wrote:

    > I am trying to use rm within an app to manage removing some files. I
    > end up with the following errors:
    >
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.DBF': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.dbf': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.zip': No such file or directory
    > /bin/rm: cannot remove `/var/www/html/informationmarket/toImport/
    > *.ZIP': No such file or director
    >
    > I know that the files are most definitely there with one of those
    > suffixes but am not sure why this happens. Any suggestions?



    How do you call "rm"? Via a "system()" call or via an
    "exec..." call?
    The wildcards are expanded by the shell, and that's missing
    if you use the exec family of calls. Then "rm" tries to delete
    ONE file named "*.DBF", and files with an asterix in the name will be
    definitively not there....
    -------------------------------------------------
    #include
    #include
    main ()
    {

    execlp("/bin/rm","/bin/rm","*.DBF",NULL);
    }
    -----------------------------------------------
    ../test
    /bin/rm: cannot remove `*.DBF': No such file or directory

    -------------------------------------------------
    #include
    #include
    main ()
    {

    system("rm -f *.DBF");
    }
    ------------------------------------------------

    works as intended


    Kind Regards,
    H.Janssen




+ Reply to Thread