Solved

Unix help

Posted on 2015-01-08
3
183 Views
Last Modified: 2015-01-19
Hi Experts,

I see in perl logs, it will tell what functions its calling using caller function and also we can see the trace of the code.

In same way is it possible in shell script we can trace the code in logs  ?

Thanks for your help in advance.

Thanks
0
Comment
Question by:magento
3 Comments
 
LVL 1

Assisted Solution

by:Mahesh Y
Mahesh Y earned 200 total points
ID: 40539598
If it is a bash script..You can enable debug mode by adding set -x below shebang or run the script with bash -x <script>
0
 
LVL 5

Author Comment

by:magento
ID: 40540531
Mahesh,

Yes, please explain how to get them in the logs when the bash script moved to production.

Thanks
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 300 total points
ID: 40541001
you can put

#!/bin/bash -x

at the beginning of your script and this will display commands on screen while running script. If you want this to be sent to logs file then you can redirect the script like:

/path/to/script >> /path/to/logs 2>&1
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

777 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