ismahwati
asked on
run script
Hi..
when i run my backup script on solaris,
$ sh fullbackup.sh
i be able to see the backup process
running on the screen.
how to do;
1) run sh and be able to see the
process on the screen and
the process running in a file .
( using sh xx > filename)
thanks.
when i run my backup script on solaris,
$ sh fullbackup.sh
i be able to see the backup process
running on the screen.
how to do;
1) run sh and be able to see the
process on the screen and
the process running in a file .
( using sh xx > filename)
thanks.
I prefer to use tee. It replicates standard output to a file, just what you are looking for. For example:
sh fullbackup.sh | tee /usr/local/logs/fullbackup .20020519
Regards, Nisus
http://www.omnimodo.com
sh fullbackup.sh | tee /usr/local/logs/fullbackup
Regards, Nisus
http://www.omnimodo.com
ASKER
i have tried solution suggested
by Nisus,
i'm not quite happy because
it just produce me the output
not the whole process flow.
anyway, it helps too.
now, i'm trying solution by kidambi.
by Nisus,
i'm not quite happy because
it just produce me the output
not the whole process flow.
anyway, it helps too.
now, i'm trying solution by kidambi.
For debugging, we use /bin/sh -x
For traces of system calls use:
truss -f /bin/sh fullbackup.sh
To make things easier for yourself, make the first line of the script:
#!/bin/sh
and do:
chmod +x fullbackup.sh
Then you can run it by entering just the scriptname.
Regards, Nisus.
For traces of system calls use:
truss -f /bin/sh fullbackup.sh
To make things easier for yourself, make the first line of the script:
#!/bin/sh
and do:
chmod +x fullbackup.sh
Then you can run it by entering just the scriptname.
Regards, Nisus.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tq..this one works as what i want to do.
others thanks for the contribution.
anyway,
what actually 2>&1 means>
others thanks for the contribution.
anyway,
what actually 2>&1 means>
2> means redirect the 'stderr' output
> (or 1>) means redirect the 'stout' output.
the number stand for the filenumber. By default 0 is stdin, 1 is stdout and 2 is stderr.
2>&1 means redicerct the 'stderr' output towards filenumber 1 (which is stdout).
As piping only passes data comming from stdout (fileno1), the 'trick' 2>&1 lets stderr points towrds stdout. As result data comming from stderr and stdout are both passed thru the pipe.
some remarks:
if you combine 2>&1 and file redirection >file. the order in which the redirections are put are VERY important.
try things like :
prog > file1 2> file2: stout is written to file1, stderr is written to file2
prog > file 2>%1 : all output is written to file
prog 2>%1 > file : stdout data is written to file but stderr output is written to where stdout pointed to originally (which is your tty/screen)
Thus in the case someone want to 'pipe' only the error messages, the following must be done:
prog 2>&1 >normel_file_output | prog_to_handle_err_output
> (or 1>) means redirect the 'stout' output.
the number stand for the filenumber. By default 0 is stdin, 1 is stdout and 2 is stderr.
2>&1 means redicerct the 'stderr' output towards filenumber 1 (which is stdout).
As piping only passes data comming from stdout (fileno1), the 'trick' 2>&1 lets stderr points towrds stdout. As result data comming from stderr and stdout are both passed thru the pipe.
some remarks:
if you combine 2>&1 and file redirection >file. the order in which the redirections are put are VERY important.
try things like :
prog > file1 2> file2: stout is written to file1, stderr is written to file2
prog > file 2>%1 : all output is written to file
prog 2>%1 > file : stdout data is written to file but stderr output is written to where stdout pointed to originally (which is your tty/screen)
Thus in the case someone want to 'pipe' only the error messages, the following must be done:
prog 2>&1 >normel_file_output | prog_to_handle_err_output
sh -x fullbackup.sh
(here you can see step by step procedure of what is happening) if you want you can open a script file and save the file.
if you want to open a script file, run the following commands
script -a /your/dest/directory/fullb
sh -x fullbackup.sh
Try your luck
kidambi