?
Solved

run script

Posted on 2002-05-18
7
Medium Priority
?
281 Views
Last Modified: 2013-12-27
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.

 
   
 
 
0
Comment
Question by:ismahwati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Expert Comment

by:k.kidambi
ID: 7019843
try running your sh command with sh -x option.

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/fullbackup.log
sh -x fullbackup.sh


Try your luck
kidambi
0
 
LVL 5

Expert Comment

by:Nisus091197
ID: 7020126
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
0
 

Author Comment

by:ismahwati
ID: 7022911
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.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 5

Expert Comment

by:Nisus091197
ID: 7023322
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.
0
 
LVL 3

Accepted Solution

by:
elfie earned 200 total points
ID: 7028209
if you need error output also

sh fullbackup.sh 2>&1 | tee fullbackup.20020519

in ksh
0
 

Author Comment

by:ismahwati
ID: 7028815
tq..this one works as what i want to do.
others thanks for the contribution.

anyway,

 what actually 2>&1  means>
0
 
LVL 3

Expert Comment

by:elfie
ID: 7029201
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

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question