Enabling server mode
Bill Fink
yellowdog-general@lists.terrasoftsolutions.com
Tue, 10 Aug 2004 22:25:17 -0400
On Tue, 10 Aug 2004, Atro Tossavainen wrote:
> > > printf '\1\2\3' > powerup-boot
> >
> > This is again bash specific. On my shell (tcsh) this just gives:
> >
> > gwiz% printf '\1\2\3' > powerup-boot
> > printf: \1: invalid escape
>
> As far as I can tell, it's not bash specific. Since printf(1) is a
> system utility, the aberrant behaviour (i.e. using a shell internal
> instead of loading a system utility) is the one that is specific to
> something (a shell that has an internal printf that works differently
> from the system utility) and as far as I can tell, the culprit appears
> to be tcsh.
>
> I could reproduce the "invalid escape" on YDL 2.3 tcsh 6.10-6, FC1
> tcsh 6.12-4, and Debian 2.2 tcsh 6.09.00-10.
>
> I couldn't reproduce it on whatever tcsh is installed by default in
> IRIX 6.5 and Solaris 8.
>
> A tcsh 6.11.00 compiled by yours truly from original sources doesn't
> have the problem on Solaris 8 or IRIX 6.5, but does on Linux...
Well it's not specific to tcsh. The system command printf has the
same problem:
gwiz% /usr/bin/printf '\1\2\3' > sample-file
/usr/bin/printf: \1: invalid escape
I think this is because, according to the man page, the escape sequence
is supposed to be 3 characters, e.g. octal:
gwiz% /usr/bin/printf '\001\002\003' > sample-file
gwiz% od -t x1 sample-file
0000000 01 02 03
0000003
Or hex:
gwiz% /usr/bin/printf '\x01\x02\x03' > sample-file
gwiz% od -t x1 sample-file
0000000 01 02 03
0000003
Also, I remembered that if you want to force use of the system command
rather than the shell built-in (or an alias), you can just precede the
command with the '\' character. For example, in my tcsh shell, the
earlier suggestion of:
gwiz% echo -ne "\001\023\001" > powerup-boot
doesn't work, as shown by od:
gwiz% od -t x1 powerup-boot
0000000 2d 6e 65 20 01 13 01 0a
0000010
BTW that's "-ne \x01\x13\x01\n".
But preceding the "echo" command with the '\' character forces use
of the system "echo" command and works fine:
gwiz% \echo -ne "\001\023\001" > powerup-boot
gwiz% od -t x1 powerup-boot
0000000 01 13 01
0000003
Finally, thanks to Walt Pawley's info on the xxd command. That could
come in really handy some day, if I can only remember about it then. :-)
-Bill