• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Qshell Logout Script

    November 3, 2004 Hey, Ted

    I know about the special scripts that run automatically when I begin a Qshell session. Is there a way to make Qshell run a script when I end a session?

    –Matt

    Qshell does not support an automatic logout script, but you can tell Qshell to run a script when the session ends by trapping the EXIT pseudo signal.

    Suppose you want to keep a log of your Qshell sessions. You might create an IFS file to contain the log information. The following command creates a file called qsh session history.

    touch 'qsh session history'
    

    Using the text editor of your choice, add the following lines to the .profile file.

    echo "$LOGNAME logged in $(date)"  >> 'qsh session history'
    trap '. $HOME/logoff.qsh' EXIT
    

    The echo command writes your user name and current date and time to the qsh session history file. The trap command tells Qshell to execute the logoff.qsh script, which is in your home directory, in the current process when the session ends. By the way, you can use the number 0 (zero) instead of the word EXIT if you prefer.

    After saving the changes to your .profile file, key the following command into a file called logoff.qsh in your home directory.

    echo "$LOGNAME logged out $(date)"  >> 'qsh session history'
    


    This command writes the date and time when you end a Qshell session to the qsh session history file. The result is a file that looks like this:

    THOLT logged in Wed Nov 3 13:07:20  2004
    THOLT logged out Wed Nov 3 13:15:18  2004
    THOLT logged in Wed Nov 3 16:27:26  2004
    

    –Ted

    Click here to contact Ted Holt by e-mail.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    VISUAL LANSA 16 WEBINAR

    Trying to balance stability and agility in your IBM i environment?

    Join this webinar and explore Visual LANSA 16 – our enhanced professional low-code platform designed to help organizations running on IBM i evolve seamlessly for what’s next.

    🎙️VISUAL LANSA 16 WEBINAR

    Break Monolithic IBM i Applications and Unlock New Value

    Explore modernization without rewriting. Decouple monolithic applications and extend their value through integration with modern services, web frameworks, and cloud technologies.

    🗓️ July 10, 2025

    ⏰ 9 AM – 10 AM CDT (4 PM to 5 PM CEST)

    See the webinar schedule in your time zone

    Register to join the webinar now

    What to Expect

    • Get to know Visual LANSA 16, its core features, latest enhancements, and use cases
    • Understand how you can transition to a MACH-aligned architecture to enable faster innovation
    • Discover native REST APIs, WebView2 support, cloud-ready Azure licensing, and more to help transform and scale your IBM i applications

    Read more about V16 here.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    PeopleSoft Updates Its Other World i5 Model 595: Big Bang for Big Bucks

    Leave a Reply Cancel reply

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle