LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-13-2013, 10:15 AM   #1
bic
Member
 
Registered: Jan 2005
Distribution: MythDora 3.2, RHEL 6.3
Posts: 101

Rep: Reputation: 16
last script run


Is there a way to get the last script run?

For example, I know I can do echo $? to get the result code and echo $0 inside the script, but how could I tell what script it came from if I chain them together like:

t1.sh && echo $(previous script filename) $? && t2.sh && echo $(previous script filename) $?

t1.sh
echo hello there

t2.sh
echo hello there to you too.

output:

hello there
t1.sh 0
hello there to you too.
t2.sh 0
 
Old 06-13-2013, 10:49 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Try the history command and then filtering the result to grab only the past script information you're seeking.
 
Old 06-13-2013, 07:46 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you chain them together with '&&', I don't think its possible (I could be wrong).
On the other hand, if you called them from within each other it t1.sh contains a call to t2.sh, then you can check PID, PPID and work your way back up the chain if you want to go further.
Perhaps you could tell us a bit more about what you're trying to achieve and why.
There may be a better way.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
If I push a button on one input device, have one script run, else, run the other? Automatic Linux - Software 2 04-14-2013 02:17 AM
My BASH script work perfect when i run it manualy, but not when it run in the crontab roqarg Linux - Newbie 30 05-06-2010 01:37 PM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration