We help IT Professionals succeed at work.
Get Started

unable to list current users logged in via SFTP client

Last Modified: 2012-05-11

I have an SFTP server running on a Debian box, used for clients to upload data and other files to us. I've got a script running which picks up those files and delivers them to a windows server share for the office staff to pick up. My problem is this:

I'd like to add a little routine in the script to check whether the client is currently logged in (so potentially in the process of uploading files) before moving said files away and risking grabbing one that hasn't been completely transfered. I tried doing it with the following lines in my script:

logontest=$(ps auwx | grep -v grep | grep "username" | wc -l)

if [ $logontest -gt 0 ]; then

exit 0

Open in new window

which would work in theory, but when this particular client connects, for some reason I don't get him listed in the output from ps. I see his login in auth.log, but he doesn't spawn a "username"@notty process or anything. Now I've connected as this user (using filezilla from another machine) and checked that I definitely do show up in ps, so it may be something peculiar about the software they're using (SecureCRT form a windows box AFAIK)

Just wondering if anyone can suggest a way to resolve this, or another way to check for a current connection from this user (using his IP or something?)

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE