I need a script to test ps -ef |grep ssh-agent, then execute eval `ssh-agent` and  ssh-add if the process is not running

Posted on 2012-09-06
Last Modified: 2012-09-06
Hi experts.
I need a script to test ps -ef |grep ssh-agent, then execute eval `ssh-agent` and  ssh-add if the process is not running.

Ibm Aix 5.3.
Question by:LindaC
    LVL 68

    Accepted Solution

    if ! ps -ef | grep -v grep | grep -q "ssh-agent" ; then
      eval $(ssh-agent)
      ssh-add # specify filename(s) here if required
    LVL 8

    Author Comment

    Thanks, trying.
    LVL 8

    Author Closing Comment


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
    Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap ( Version 1.2 2.      Jpcap( Version 0.6 Prerequisite: 1.      GCC …
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    734 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

    23 Experts available now in Live!

    Get 1:1 Help Now