Solved

Unix help

Posted on 2015-01-08
3
181 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now