Capturing console (/dev/ttyS1) logs

Hi,

I have been trying to capture console logs from the init script.
When the ramfs is mounted, i check if usb is connected , if conncted, i mount it and redirected the console logs like so:

cat & /dev/ttyS1 >> /mnt/logs.txt

I'm getting

/bin/sh : /dev/ttyS1 :permission denied

I tried changing the permission to 777, but to no avail.:confused:
I also tried sudo, and found out that our ramfs does not support this command.
The console logs are still being printed on the monitor.

Please suggest a solution.

Thanks.

What OS are we dealing with?

Are you logged in as the root user?
If so, is the output from dmesg enough?

This is on an embedded device with Linux 2.6.27.39-grsec.

dmesg only gives kernel logs, the logs i intent to collect come from the ramfs, before booting the kernel.

:confused:

there was a command called screendump similar to setterm -dump which get details from ttys

Something similar to:
Linux.com :: Everything Linux and Open Source

2 Likes

:rolleyes:...hmmm

That's interesting, not sure whether our ramfs had that command, but ill try that too....

Thanks.:b:

setterm is packaged with util-linux for RHEL, in case you need to track down the source.

I'm not sure this will meet your needs in the long-term, since that command will do only 1-time snapshots. So in the long-term, in your rc/init files, replace "echo" with "logger -s". You could implement this with a function that's included by every rc file:

echo() {
  /bin/logger -s -f /var/log/rc-init-messages -p local0.info -t "$0" -- "$*"
}

But the file must exist first, so "touch /var/log/rc-init-messages" at the top of this include file.

My first thought would be to try ttysnoop.

(would post more but the HTML detect script swears I'm trying to post a URL thoguh I am not)

cat & /dev/ttyS1 >> /mnt/logs.txt

This is wrong. The & breaks it into two commands.

cat /dev/ttyS1 >> /mnt/logs.txt