Solved

Unix help

Posted on 2015-01-08
3
185 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
[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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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