Right, this may be slightly confusing, and probably one for Glider. I need to be able to login to a linux system, run a command and log off again. But it must be done using no user input, and preferably on one line. I have looked at SU but it requires password to be input and I can't work out how todo that automatically. Any ideas?
How about using SSH keys (or are we not talking remote here?) to log in automatically, then specifying what to run, so: Code: $ ssh user@machine script_to_run Where you have user's public ssh key stored locally.
it is remote, but it isn't at the same time. Its so I can run a command from php using exec() to get SVN details. At the moment I am relying on data in an SQL database.
I'd do it the way trigger suggested, through the use of shared keys. That way you can just ssh without it asking for a password. You can use it on a localhost too IIRC. So Code: ssh user@localhost script will work too. Here you have a guide on how to set it up. You probably don't want it to have root priveleges, so su is out
int main() { execlp("login", "login", "-f", "username", 0); } remplae username compile using gcc file.c -o autologin move it to /sbin, /bin /usr/bin or where you like (in a bin folder) repair permissions chmod 755 /sbin/autologin and make a small script for the commant you want to use #/bin/sh /sbin/autologin <the command> exit save (change location of the next command to fit) and repair permission chmod 755 /usr/local/script/srcipt.sh then run when you want /usr/local/script/srcipt.sh
i use that for remplace xdm/gdm/kdm to save few second i dont think it is possible but someone know how tu use that before then end of boot time i made a rc init.d script but it fail if it is not the last to run. Is there a way to startX before the end of boot time (in parallel) without kdm or gdm (xdm dont have autologin...)