[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a question on C++




I think you mean this:

On Tue, 10 Jul 2001, Tzafrir Cohen wrote:

> #!/bin/bash
>
> # create empty run.log and error.log
> echo -n >run.log
> echo -n >error.log

Also
$ > run.log
$ > error.log
works (no need for echo).

> for PARAM1 in val1 val2 val3; do
>   for PARAM2 in val4 val5 val6; do
>     ./myprog $PARAM1 $PARAM2 2>1 >>run.log

You mean "2>&1", "2>1" just redirect stderr to file "1", also it does
not still work, if you have been read BASH(1), you know that you
should write "./myprog $PARAM1 $PARAM2 >>run.log 2>&1", this order is
the correct one, in yours, you first redirect stderr to terminal [that
is the current file attached to stdout], then redirect stdout to
run.log.

>     # or maybe you would rather use:
>     #./myprog $PARAM1 $PARAM2 >>run.log 2>>error.log
>   done
> done
>
> (There is also a more premitive and less convinient 'nohup' program)

As I know, the modern systems does not need nohup, I tried the piece
below on redhat 7.1:

--- a.c start
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>

int
main()
{
  int f;
  f = open ("log", O_RDWR | O_CREAT, 00600);
  while (1)
    {
      sleep (1);
      write (1, ".", 1);
      write (f, ".", 1);
    }
  return 1;
}
--- a.c end

compiled it, and ran it in background using "./a.out &", it
started writing dots on both the terminal and the file "log", the
logout, and relogin, ps reported a.out attached to terminal "?", and
filesize of "log" was still growing, showing that ./a.out is still
running in background, ...

yours,
-- 
Behdad
19 Tir 1380, 2001 Jul 10

[Finger for Geek Code]



=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il