You are not logged in.
I'm coming from Ubuntu to Arch Linux, I'm trying to autostart an interactive program written in C++ at boot before tty1 appears.
I have created a file called /etc/systemd/system/myapp.service with the following contents:
[Unit]
Description=myapp
[Service]
Type=oneshot
ExecStart=/home/xxx/myapp.exe start
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
And then run
sudo systemctl enable myapp
Unfortunately, it does not work as expected:
1. I can't interact with myapp
2. I do not want tty1 to appear until the program ends
Last edited by mafrek (2013-09-05 07:30:45)
Offline
now i get my app working before tty appears
/etc/systemd/system/myapp.service now contents:
[Unit]
Description=myapp
After=sysinit.target
[Service]
Type=oneshot
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start
[Install]
WantedBy=multi-user.target
But still I can not interact with my program
my simple c++ code :
#include <iostream>
int main(){ std::string str;
std::cout << "############" << std::endl;
std::cout << "Enter Youre Name: ";
std::getline (std::cin,str);
std::cout << "Welcome "<< str << std::endl;
std::cout << "############" << std::endl;
return 0;
}
Offline
How do you intend to interact with it if the tty hasn't been initialized? That code does not replicate (a)getty's behavior, but assumes that it has already been done.
If you are writing your own login program, you still need something to set up the tty - this is what {a,min,)getty is for. With some of these including agetty, you can specify an alternate login progam with the -l parameter, wich looks like what you are trying to do.
Or perhaps you just want auto login and want to customize /etc/issue.
The big question then, is what are you really trying to do?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
i just hope to execute my above simple c++ code at bootup And interaction with it.
I've done this before, under ubuntu with init technique but i don't know do that in arch linux.
apology for my poor english.
thank u
Offline
I guess a good idea would be to run your application with rungetty or maybe agetty with --skip-login and --login-program set to your binary.
You could also look at the code in ask-password-api in systemd I guess.
http://cgit.freedesktop.org/systemd/sys … word-api.c
Last edited by progandy (2013-09-05 15:08:53)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
mr.progandy
rungetty in arch ! How install it , How does it?
Offline
mr.progandy
rungetty in arch ! How install it , How does it?
It is in the AUR.
You might not need it, though. systemd can open the tty for you
User=nobody
StandardInput=tty
StandardOutput=tty
StandardError=tty (or maybe journal+console to log error data)
Last edited by progandy (2013-09-05 16:18:54)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
thank you . thank you . thank you .
the secret thing in magic line `StandardInput=tty`
my final /etc/systemd/system/myapp.service
contents:
[Unit]
Description=myapp
After=sysinit.target
[Service]
Type=oneshot
StandardInput=tty
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start
ExecStop=/home/xxx/myapp.exe stop
[Install]
WantedBy=multi-user.target
AND i disable tty1
sudo systemctl disable getty@tty1.service
Now tty1 is my app (-:
Another problem )-:
ExecStop=/home/xxx/myapp.exe stop
not working, i want run myapp with stop parameter on shutdown/reboot system
thanks for ( Trilby, progandy )
Last edited by mafrek (2013-09-06 09:43:13)
Offline
I guess a good idea would be to run your application with rungetty or maybe agetty with --skip-login and --login-program set to your binary.
You could also look at the code in ask-password-api in systemd I guess.
http://cgit.freedesktop.org/systemd/sys … word-api.c
Wonderful , This advanced, Is not the time to use this but realy linux is great, awesome
thank u
Offline