Using: CentOS 6.2 BASH Script

I regularly install CUDA (a GPU programming API) on machines in my work cluster, and have to reupgrade three *.run installers whenever I do an upgrade version-wise.

The installers are semi-predictably named (though NVIDIA sometimes changes up the naming scheme) so I've created a script that switches to the root user, takes the run level down to 3 to turn off any running X server instances, calls the most RECENT version in my installers directory with sh ls -t base_<name>*.run|head -n 1 and then finally switches the run level back to 5.

Now this is nice as it reduces intervention, but what I really would love to do is automatically input the enter/arrow sequences to the *.run autonomously from the script, as they're the exact same every time. Is there a good way to do this for *.run files?? You don't have to give me a full answer even, just pointing me towards a good tutorial would be educational.

Also, on the odd chance someone with CUDA experience sees this, any idea if there's a repository that I can get the latest dev drivers; gpu tools installer (nvcc, etc.); and gpu SDK from? (these are my three *.run installers) I can go in my browser and download all of these, but a command line scriptable way would be super nice as then I'd cut out one more step! :)

  • 1
    Have you tried passing -h or --help to see if you can use arguments to automate it? Apr 13, 2012 at 20:07
  • @IgnacioVazquez-Abrams Typing this (plus sh gave a "Getting" and "Running" section. The part that sounds promising was in the Running section which says that option -- results in Following arguments will be passed in the embedded script. Assuming this is what I need, how do I tell what those argument are? Apr 13, 2012 at 21:32
  • Try passing -- -h then. Apr 13, 2012 at 21:37

1 Answer 1


You can try coding up an Expect script to handle this. I'm not sure if it can do arrow keys, but I've used it to automate command line inputs to commands/scripts in the past. These links may be useful if you go that route.

  • Ah your answer is perfect... It will handle everything besides the driver.... actually knowing what to search for, I even found a post explaining how to do this: forums.nvidia.com/index.php?showtopic=195758 Apr 13, 2012 at 21:34
  • I'm glad that helped. I've used it for a few scripts and I'd feel so lost without it. It's a great tool IMO.
    – sbtkd85
    Apr 16, 2012 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .