Code: Select all
#!/bin/sh
VTX=$1
USERNAME=$2
export TERM=$3
kill -19 $(lsof -t -c 'agetty' -a /dev/tty${VTX}) 2>/dev/null;
openvt -c ${VTX} -f -- sh -c "clear;/bin/login -f ${USERNAME};kill -9 $(lsof -t -c 'agetty' -a /dev/tty${VTX}) 2>/dev/null"
./scriptname vtx username linux
This script avoid some error than directly "agetty -a username ttyX linux" Linux.
That error of agetty is that target tty output error information similar following:
Code: Select all
bash: cannot set terminal process group ("random pid of login"): Inappropriate ioctl for device
bash: no job control in this shell