You have to create a startup script. Look in System/StartUpItems/ (not in X so it may be named slightly differently) and copy one of those folders to your user directory. Edit the files in this folder (start up item folder) so that they start the CLI app you want to start and then create a folder in your USERNAME/Library/ directory called StartUpItems/ (again I'm not in X at the moment so you need to check the name) and place the folder (start up item folder) in there.
Hope this makes since. This not for the faint hearted.
Good luck,