The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
joining command results, and substitution ncatdesigner Shell Programming and Scripting 6 04-17-2008 12:37 PM
Formatting Substitution Command Not Working in vi ERPKEN UNIX for Advanced & Expert Users 11 05-06-2007 10:36 PM
complex command substitution spopuri Shell Programming and Scripting 5 05-24-2006 09:37 AM
command substitution problems with csh using grep voodoo31 Shell Programming and Scripting 2 01-14-2006 07:39 AM
Preserving space during command substitution Sabari Nath S UNIX for Dummies Questions & Answers 1 10-04-2005 10:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-16-2005
ghazi ghazi is offline
Registered User
  
 

Join Date: Dec 2004
Posts: 15
Substitution of last command

"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only.

Thanks in advance for your usual help.

Ghazi
  #2 (permalink)  
Old 01-16-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I'm not too sure I follow - if you want to rerun the last command each shell has a different syntax to allow this - the last command shows a history of logins, not commands. Some OS's provide the lastcomm command if accounting is enabled, although this may require superuser privileges.

You can look into fc -e -, I always alias this (if not pre-aliased) to r in Bourne-type shells thusly:

alias r='fc -e -'

Then you can do stuff like

$ r ls
ls -la /my/dir


which will execute the last command in your history (providing your shell supports history) starting with "ls".

As I say, each shell supports differing history syntax and functionality, please post the output of
echo $0
echo $SHELL
uname -a
plus a further rundown of your exact requirements for a more detailed solution.

EDIT: Looking back at your OP, do you want to run last as a user that doesn't have the privilege to run the command? If so sudo may be the solution.

Cheers
ZB

Last edited by zazzybob; 01-16-2005 at 05:35 PM..
  #3 (permalink)  
Old 01-16-2005
ghazi ghazi is offline
Registered User
  
 

Join Date: Dec 2004
Posts: 15
I apprecate your quick response.

I am hp and using tcsh. I am not looking for whodo command output (output from the who, ps and acctcom) rather I am ONLY interested to find out when particular user was last time logged on to the system. Is there any way I can find out this if logged in as a develper (not root).

Thanks,
Ghazi
  #4 (permalink)  
Old 01-16-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
last is supposed to be a user command. I just tried it on HP-UX 11.0 and it works fine for ordinary users.
  #5 (permalink)  
Old 01-16-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I just tried it telnet-ing into the HP-UX 10.20 box at work and last works fine, also; I tried it on a bunch of Linux boxes, Solaris 9, and UNICOS and it works without a hitch.

Cheers
ZB
  #6 (permalink)  
Old 01-16-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
Try using the full path: /usr/bin/last. If you still have trouble, tell us exactly what happens.
  #7 (permalink)  
Old 01-16-2005
ghazi ghazi is offline
Registered User
  
 

Join Date: Dec 2004
Posts: 15
What could be the reason it is not working for me?

Thanks.
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0