[solved] hook to run commands when user logs in? (before bash profile)

Is there any way to run commands when a user logs in but before the bash profile is sourced?
For example, I have a user account with a home directory on /tmp. When the user logs in, the home directory might not exist so there will be no .bash_profile to source. I want to run a script to create the directory if necessary and copy some files into it. How can that be done?
I thought of putting something in /etc/profile or /etc/profile.d/, but I would like to run something before the user's shell and environment become active.
I can use /etc/rc.local to do what I want, but I would prefer a hook to ensure that everything is set right when the user logs in.
Any ideas?
*edit*
Solution
In my case, I found that I could write my own shell script and set it as a login shell. In the script, I can configure everything I need before launching the interactive shell, then clean up anything after it exits.
Last edited by Xyne (2011-12-10 19:34:07)

Thanks, dammannj. PAM could probably do what I need but I think I have found a simpler solution (see original post).

Similar Messages

  • Unable to capture trace, when user logs in throuigh Web Interface

    The Trace shows 'No Records Found', when user logs in through Web Interface of CRM. But there is Trace found, when the same user logs in through logon pad and carries out normal actvities.
    sufficient auth. is provided.
    Is there any setting in ST01, through which i can get trace , when user logs in through Web Interface
    Regards

    ST10 traces 1 instance only.
    Your CRM web interface could use another instance than your backend. Go to transaction SM21, choose the appropriate server and run ST10 again.
    Succes!
    Kind regards,
    Lodewijk Borsboom

  • How to run GINA when windows log off ?

    I test pGina program which was create from GINA. I want create program for logon windows with C#. I wonder when user log off windows why pGina can run application for login windows. I think application can run when start windows only . How pGina can run
    program when user click log off button ?

    Hi mmc01,
    I'm afraid you posted your question on the wrong forum. This forum is dedicated to Project Server concerns, the Microsoft enterprise scheduling & planning application.
    Please go to an appropriate forum in order to have an helpful hand.
    Cheers.
    Guillaume Rouyre - MBA, MCP, MCTS

  • Can't run command because user is in read-only mode.

    Hi
    I try to execute any sql statment i am getting this error.
    Can't run command because user is in read-only mode.

    user493528 wrote:
    I am having the same issue with Benthic when I do the With clause.
    I understand this is not related to Oracle but did anyone had issue related to this. I am getting the same error. Is it related to ODBC driver of how Benthic use to connect etc.,? I do not know.
    Thanks
    Gopihttp://www.benthicsoftware.com/support.html

  • How to trigger a custom code when user log in?

    Hi my friends,
    We are using multiple sharepoint sites at work. Users log in with AD accounts, so they dont see any login page.
    I need to run a custom code when user login to website. Event receivers do not help at this point. Any suggestions?
    thanks in advance

    Hi Ahmet,
    From your description, my understanding is that you want to trigger some custom code when users log in SharePoint.
    As a solution, you could customize a login page for your SharePoint, then you could trigger your code.
    You could also use httpmodule to monitor user login. Please refer to this article about how to use httpmodule:
    http://sharepoint.stackexchange.com/questions/100976/get-the-current-logged-in-user-in-sharepoint-added-httpmodule
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Issue where the cart is empty when user logs back in

    Having issue where the cart is empty when user logs back in
    Steps:
    1. User logs into the site
    2. User selects items and the cart is updated
    3. User logs out of their account
    4. User exits/closes the browsers
    5. User then reopens the browser, navigates to the site, logs in and the cart is empty
    My understanding is that the cart should be populated with the previous items since the user did not complete the order.
    I have the following settings:
    in shoppingcart.properties
    persistOrdersForAnonymousUsers=true
    persistOrders=true
    in cookieManager.properties
    sendProfileCookies=true
    in /atg/userprofiling/ProfileRequestServlet.properties
    verifyBasicAuthentication=true
    in /atg/dynamo/servlet/dafpipeline/ProfileRequestServlet.properties
    persistAfterLogout=true
    persistentAnonymousProfiles=true
    Anything else that needs to be set?
    Edited by: boyd4715 on Feb 6, 2013 11:07 AM

    I reset the properties back to their orignal state
    in shoppingcart.properties
    persistOrdersForAnonymousUsers=false
    persistOrders=true
    in cookieManager.properties
    sendProfileCookies=true
    in /atg/userprofiling/ProfileRequestServlet.properties
    verifyBasicAuthentication=false
    in /atg/dynamo/servlet/dafpipeline/ProfileRequestServlet.properties
    persistAfterLogout=false
    persistentAnonymousProfiles=false
    in /atg/userprofiling/ProfileTools.properties
    mergeOrder=false;
    Observateion:
    If an anonymous user comes to the site, adds items to the cart, leaves the site and comes back - the cart is empty - the order repository is not updated
    If a user logs into the site, adds items to the cart and then exits the browser (does not log out), comes back to the site, the selected items are in the cart
    If a usr logs into the site, adds items to the cart, logs out of the site, exits the browser, comes back to the site, the selected items are not in the cart
    An order does not get presisted to the repository until the order is confirmed.
    Based on the last item that explains why the user is not seeing any anything in their cart when they log out. If they do not log out, I assume then that the content of their cart is stored in the cookie.
    So, now the question is - why is this happening - I am not the original author of the site - just trying to get some things fixed on it.

  • Launchd - can it run a script when users log in OR switch?

    I'm hoping to find someone who knows all the gory details of launchd. Here's the why and what: I'm trying to coerce Aperture into letting two users on the same computer share the same Aperture Library, both able to import photos and see and use what the other has done. Initially it is no problem, change the permissions so everyone has read/write/execute, put the Library in a common area, and point both person's Aperture at it. The problem is that Aperture changes permissions of things inside the Library as you use it, and especially when one person imports, the other person can't see that stuff.
    So I want to run a script whenever someone logs in or becomes the active user by fast user switching; the script will simply change ownership and permissions of the library and everything in it to restore full access.
    After days of research and testing, I made a test launchd plist file (this is the configuration file or agent that launchd looks at and runs your script when criteria are met). It sits in /Library/LaunchAgents/, here it is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>org.jim.test</string>
    <key>LimitLoadToSessionType</key>
    <string>LoginWindow</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Library/Scripts/testscript.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/Users/jim/Desktop/test.err</string>
    <key>StandardOutPath</key>
    <string>/Users/jim/Desktop/test.out</string>
    </dict>
    </plist>
    The actual test script is sitting in /Library/Scripts/:
    #!/bin/bash
    echo "org.jim.test.plist was run at `date`"
    So if the plist is loaded and the script run, the date and time are written in the test.out file on my desktop. This thing runs great when a user logs in. The problem is, it doesn't run when users switch by fast user switching. In reading the documentation, it was vague about this, whether that could be done; I thought it could.
    Can anyone help with a way to get the script to run when any user takes control by any means? As an added complication, which I'll worry about later, the script has to run as root because it's the only way to get the ownership and permissions changed.
    Thanks,
    Jim

    BobHarris is the MAN. ACLs seem to have worked. I put the Aperture Library in /Users/Shared/ApertureLibrary, restored the regular permissions as best I could (me as owner, staff as group, 755), pointed each person's Aperture to the library, then proceeded with the ACL magic. First I created a group for my wife and I, called 'aperture', in the Accounts preference pane. That was to simplify the ACLs (one entry instead of 2) and so that other users (son) aren't able to muck it up.
    It took one stinking Terminal command (note that 'aperture' at the beginning of the quote is the group, not the program, folder or library):
    chmod -R +a "aperture allow list,addfile,search,delete,add_subdirectory,delete_child,file_inherit,directoryinherit" ApertureLibrary.aplibrary
    I was unsure whether this list of permissions was necessary or sufficient, but it seems to have worked so far. Both users can access the library. I imported a different picture by each user, and the other user could then see and delete the picture imported by the other. This was not possible before.
    Bob, thanks for the great idea. After a little more testing I'll post a complete how-to in the latest "how do we share Aperture" thread, and give you due credit. The bad news is all the launchd fun is over
    Jim

  • Run LabVIEW executable when user logs off

    I have a customer request to do this.
    My customer has a computer in their plant that I wrote a LabVIEW applicaiton to monitor part of their process.  This computer performs other functions in addition to my program.  Their IT department has changed their policy that mandates that anybody using this computer has to log in under their own user name and password.  Prevoulsy it was just a group  user name and password.  What this means for me is everytime a new user needs to use the PC they have to log off and log back on.  This stops my program.
    Is there a way to have a LabVIEW executable keep running when different users log off and log on?
    Thanks
    Dan

    Sounds like you need a service. It may be a complete architecture change, but you could have an executable running as a service and a user interface executable connecting to it (e.g. via TCP/IP). The service itself can't have a UI.
    Without using a service there's no way an application can continue running when a user logs off (afaik).
    A service is started even if no user logs on.
    There's tools like srvany or similar that allow to run an executable as a service.
    Daniel
    Message Edited by dan_u on 08-18-2009 03:13 PM

  • Java dying when user logs off machine

    I have developed a class that monitors a MQ queue, I used the active-x bridge to allow distribution to both java and VB developers to use. The application that is to be developed should be running on a machine in the background.
    I created a test VB program using the java class and created a "scheduled task" to start on system start up. When I start the machine, the application starts up and runs. Then a user logs into the machine, and application is still running. Then the user logs off the machine, and the program stops.
    I have a VB porgram without the java active-x bridge object and that works throughout the login/logout process.
    Any thoughts on how I can keep the program running continously, thanks.

    Well, I found a solution. If you add the paramater -Xrs to the java command, it will reduce the use OS signals. Thus it will ignore the hook that Windows has.
    It turns out this was a bug in version 1.3. For some non-light reading and more info, see http://developer.java.sun.com/developer/bugParade/bugs/4323062.html

  • Finder window opens when user logs in

    I apologize if this has been answered previously - I can't find anything on this topic.
    Every time a user logs in to one of my eMacs - OS 10.4.10 (whether it be a local or network user) a new finder window opens that displays the users home. I would like this window to stop opening. I've read some responses that say to close the window then log out and the window should be gone when you log back in. That is not the case. I thought this solution my work on my local users but it doesn't work for either type of user.
    I'm trying to avoid writing a script to close the window. I'd like the window to just stop opening in the first place. I tried editing the finder.plist file and I can change what the window opens to, but I can't "turn off" the actual opening of the window.
    Any suggestions are greatly appreciated!
    Thanks!

    I do not have anything checked in the login items. This is happening for both local and network accounts. I'm more concerned about this issue for my network users.
    I've discovered that the problem seems to have something to do with a script I had running via a login hook. Is there any way to run a script when a network user logs in without adding it to a login hook?
    We have a program on our eMacs that resets the computer back t o its original state every time the computer is restarted. For this reason network user profiles are never stored on the eMac they are recreated from the default user template every time a user logs in.
    Maybe this extra information will help!
    Thanks!

  • Why does a LaunchDaemon stop when user logs out?

    Hi,
    We have an application that uses an older version of Jetty that I am trying to configure as a LaunchDaemon on OS X 10.7.5
    I've created a org.mortbay.jetty.plist and placed this in the /Library/LaunchDaemons, set permission 644 and owner root:wheel. This can be loaded via launchctl and all is happy. I can connect to the server and browse the pages on the server. However, if I log out, the service stops responding and only starts responding when I log in again. It appears to stop jetty and then restart it when I log in.
    As this is being run as the root user, I would not have expected a user logout to stop this process. From what I can see there are no per-user overrides for this.
    Upgrading Jetty is not currently an option.
    Any help/ideas would be appreciated.
    Dave
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
        <dict>
            <key>Disabled</key>
            <false/>
            <key>Label</key>
            <string>org.mortbay.jetty</string>
            <key>ServiceDescription</key>
            <string>Jetty 5</string>
            <key>RunAtLoad</key>
            <true/>
            <key>KeepAlive</key>
            <true/>
            <key>EnvironmentVariables</key>
            <dict>
                <key>JAVA_HOME</key>
                <string>/Library/Java/Home</string>
            </dict>
            <key>WorkingDirectory</key><!-- required! -->
            <string>/usr/local/myApp/Jetty/extra/OSX/</string>
            <key>ProgramArguments</key>
            <array>
                <string>/usr/bin/java</string>
                <string>-Djava.io.tmpdir=/tmp</string>
                <string>-Djetty.port=2000</string>
                <string>-Djetty.home=/usr/local/myApp/Jetty/</string>
                <string>-Djetty.logs=/usr/local/myApp/Jetty/logs/</string>
                <string>-d32</string>
                <string>-jar</string>
                <string>../../start.jar</string>
                <string>/usr/local/myApp/Jetty/jetty.xml</string>
            </array>
            <key>UserName</key>
            <string>root</string>
         <key>StandardErrorPath</key>
         <string>/tmp/launchd_myprogram_stderr.log</string>
         <key>StandardOutPath</key>       
         <string>/tmp/launchd_myprogram_stdout.log</string>
          </dict>
    </plist>

    Thought I had an answer...but no.
    Maybe this reference will help:  Daemons and Services
    Message was edited by: g_wolfman

  • Copy apps using HFM Copy application utility when users logged in.

    Hi All
    I am using HFM copy application utility to migrate apps across environments. Can we do the same when users are logged in and active? I know that this utility just copies tables from source to destination, but I m not sure if the copy will be successful if some of the tables are being edited.
    Thankyou,
    Raghu

    Hi,
    Dont run the HFm Copy appplication utility when apps were in use.Let say you have app1,2,3,4 and you want to move app 1, make sure app 1 is not in use.
    if some body is accessing app2 or 3 or 4 you dont want to worry about that while moving app 1.
    Thanks,
    Mugundhan

  • [SOLVED] How to run commands during logoff?

    Hi there,
    Am trying to run the command "alsactl store" upon logoff so my volume levels are stored when I LOGOFF (which I assume will also apply to restarts and shutdowns too???). But I can't seem to find the necessary rc file...
    Any help would be great!
    Cheers,
    KC
    Last edited by killercow (2008-08-30 00:46:01)

    If you are talking abt. logging off from bash/konsole, there is no file [in my head ] that we can insert our own commands into.
    Logging out of a DE session should 've their config files, but I don't know them

  • Monitoring when users Log to resources remotely

    I'm trying to monitor when users access another computer in the domain remotely.  I check out the logs from the Domain Controller on event viewer (WindowsLogs) and it shows me some events where I can see that a user logged on a sepecific machine. 
    But when I run a test my logging in to a remote server I do not see an entry tha shows anything related to an access to the remote server.
    Is there anything I need to enable on the domain controller or any other logs I can take a look at?

    Hi,
    Have you configured audit policies on the Domain Controller?
    You can use ADUC to enable auditing, more information for you:
    HOW TO: Audit Active Directory Objects in Windows Server 2003
    http://support.microsoft.com/kb/814595
    Configuring Audit Policies
    http://technet.microsoft.com/en-us/library/dd277403.aspx
    Best Regards,
    Amy Wang

  • System PATH environment variable issue when user log off and log in or switch from admin to non-admin account

    Hi,
    Problem Description:
    After installing my new product version, when user does log-off and log in again into admin account
    or switch from admin account to non-admin account, PATH environment variable shows incorrect path of my product (previous product version’s path) using command prompt.
    It seems windows refresh issue during session changes (log off and log in / switch from Admin to
    Non-admin account).
    Why PATH environment variable is not refresh immediately after log off and log in again or Switch
    from admin to non-admin mode?. 
    Please see my thread for more details http://social.msdn.microsoft.com/Forums/vstudio/en-US/445ab42c-bdff-405a-8d53-558e1b6c7d34/path-environment-variable-issue-when-user-logoff-and-login-or-switch-from-admin-to-nonadmin?forum=windowsgeneraldevelopmentissues
    Also submitted bug for this in connect.microsoft.com portal.In that it has lots of information
    like problem statement, Reproduction steps and Expected Results.
    Bug ID: 871782
    Could you please any body help me for this?. your support will be appreciated.
    Thanks,
    Marichamy

    Why PATH environment variable is not refresh immediately after log off and log in again or Switch
    from admin to non-admin mode?. 
    I wouldn't have any expectation of what you are doing to work the way you expect.  E.g. why is the %ABC% being replaced at all?  There is some help about this ambiguous scenario in the cmd help...
    /V:ON Enable delayed environment variable expansion using ! as the
    delimiter. For example, /V:ON would allow !var! to expand the
    variable var at execution time. The var syntax expands variables
    at input time, which is quite a different thing when inside of a FOR
    loop.
    /V:OFF Disable delayed environment expansion.
    So, what's the setting for the /V:  switch that your users would be using?  Perhaps you should be using the ! instead of the % for your ABC variable?
    Oh.  There's more below where I found that...
    Delayed environment variable expansion is NOT enabled by default. You
    can enable or disable delayed environment variable expansion for a
    particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You
    can enable or disable delayed expansion for all invocations of CMD.EXE on a
    machine and/or user logon session by setting either or both of the
    following REG_DWORD values in the registry using REGEDIT.EXE:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
    and/or
    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
    to either 0x1 or 0x0. The user specific setting takes precedence over
    the machine setting. The command line switches take precedence over the
    registry settings.
    In a batch file the SETLOCAL ENABLEDELAYEDEXPANSION or DISABLEDELAYEDEXPANSION
    arguments takes precedence over the /V:ON or /V:OFF switch. See SETLOCAL /?
    for details.
    If delayed environment variable expansion is enabled, then the exclamation
    character can be used to substitute the value of an environment variable
    at execution time.
     So, I guess the essence of your "bug" will boil down to whether you
    need the feature to get the result you want and the
    truth of that first sentence but it certainly looks like a "can of worms" to me.   ; )
    HTH
    Robert Aldwinckle

Maybe you are looking for

  • VisualVM not starting correctly

    I have on some Linux servers a weird behaviour of jvisualvm. Java --> jdk1.6.0_43 Linux + X11-Xming for graphics. The first time I start the tool, it starts coorectly. Then I close the tool and restart, and from then on I see the logo dialog, and the

  • Second battery - DEAD

    This is the second battery that I have had in less than three monhts as a new Mac user (Powerbook G4). This second battery problem, though, is slightly different. It will take a charge. However, it's life has gone to nil. Just now, I charged it up fo

  • Duplicacy in condition type

    hi all, when i m creating purchase order then in conditions it is taking duplicate condition types for every condition type while it must take only one for each. for exa : condition type -- PR00, then its showing two times.              condition typ

  • Type of invoce verification and inventory management

    Please tell me what is type of Logistic invoice verification  and Inventory management???

  • ORA-484 LMS* process terminated with error

    Instance is crashing frequently with the ORA-484 LMS* process terminated with error. Oracle RAC 10.2.0.3 on HP_UX 11i on ASM. Please advise