rg@gillxp (Richard J. Gill) (08/16/88)
I have the need be able to generate the full ASCII character set from the Bourne shell. There is no problem on my NCR Tower XP (System V); I simply use the following syntax: echo "\007" # 0x07 echo "\0212" # 0x8a ... On my Fortune 32:16 (Forpro 2.0 - Sys 3v7 & BSD 4.3), however, the string is simply displayed as a literal. Any ideas on how I can generate the fully ASCII set from the Bourne shell on the Fortune? Thanks. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ Dick Gill Gill & Piette / PSG (703)761-1110 ..uunet!gillxp!rg
tjb@Apple.COM (Tom Barrett) (08/16/88)
In article <118@gillxp> rg@gillxp (Richard J. Gill) writes: > echo "\007" # 0x07 > echo "\0212" # 0x8a > ... > >On my Fortune 32:16 (Forpro 2.0 - Sys 3v7 & BSD 4.3), however, >the string is simply displayed as a literal. Any ideas on how I >can generate the fully ASCII set from the Bourne shell on the >Fortune? Could you be using csh on your Fortune? Csh has a builtin echo command which behaves differently than echo in Bourne shell echo. Try using /bin/echo instead of echo. - Tom Barrett (408) 973-3364 Apple Computer MS 27AQ 10500 N. DeAnza Blvd. Cupertino CA 95014 {amdahl,decwrl,hplabs,sun,voder,nsc,mtxinu,dual,unisoft}!apple!tjb OR tjb@apple.apple.com Tom Barrett (408) 973-3364 Apple Computer MS 27AQ 10500 N. DeAnza Blvd. Cupertino CA 95014 {amdahl,decwrl,hplabs,sun,voder,nsc,mtxinu,dual,unisoft}!apple!tjb OR tjb@apple.apple.com
knutson@marconi.SW.MCC.COM (Jim Knutson) (08/18/88)
In article <118@gillxp> rg@gillxp (Richard J. Gill) writes: > echo "\0212" # 0x8a > ... >On my Fortune 32:16 (Forpro 2.0 - Sys 3v7 & BSD 4.3), however, >the string is simply displayed as a literal. Any ideas on how I >can generate the fully ASCII set from the Bourne shell on the >Fortune? Well, one way to do it would be to use the tr command. For instance, to repeat your examples: echo . | tr . '\007' # 0x07 echo . | tr . '\212' # 0x8a Note that tr expects to have no more than 3 digits so '\0212' won't give you what you expect. -- Jim Knutson knutson@mcc.com cs.utexas.edu!milano!knutson
leo@philmds.UUCP (Leo de Wit) (08/19/88)
In article <118@gillxp> rg@gillxp (Richard J. Gill) writes: >I have the need be able to generate the full ASCII character >set from the Bourne shell. There is no problem on my NCR Tower >XP (System V); I simply use the following syntax: > > echo "\007" # 0x07 > echo "\0212" # 0x8a > ... > >On my Fortune 32:16 (Forpro 2.0 - Sys 3v7 & BSD 4.3), however, >the string is simply displayed as a literal. Any ideas on how I >can generate the fully ASCII set from the Bourne shell on the >Fortune? On BSD you can use tr(1) which understands octal codes just in the way your echo does in System V; the two examples could be rewritten as: tr a "\007" <<EOT a EOT tr a "\0212" <<EOT a EOT The a character acts as a dummy and is translated to the octal coded character. If you use these characters a lot, it would make sense to save the output of tr into shell variables. Hope this helps? Leo.
dce@mips.COM (David Elliott) (08/19/88)
In article <1054@marconi.SW.MCC.COM> knutson@marconi.sw.mcc.com.UUCP (Jim Knutson) writes: >In article <118@gillxp> rg@gillxp (Richard J. Gill) writes: >>... Any ideas on how I >>can generate the fully ASCII set from the Bourne shell on the >>Fortune? >Well, one way to do it would be to use the tr command. For instance, >to repeat your examples: > echo . | tr . '\007' # 0x07 This is a very useful trick. One thing it doesn't handle is generating a NUL. I've tried all kinds of things, but have never found a way to generate a NUL character from a shell script. Well, I guess C is good for at least *one* thing ;-) -- David Elliott dce@mips.com or {ames,prls,pyramid,decwrl}!mips!dce
chris@mimsy.UUCP (Chris Torek) (08/19/88)
>In article <1054@marconi.SW.MCC.COM> knutson@marconi.sw.mcc.com.UUCP >(Jim Knutson) writes: >> echo . | tr . '\007' # 0x07 In article <2848@quacky.mips.COM> dce@mips.COM (David Elliott) writes: >This is a very useful trick. Aye. >One thing it doesn't handle is generating a NUL. I've tried all >kinds of things, but have never found a way to generate a NUL >character from a shell script. Use the `printf' command: $ printf %c \\0 Surely you have a printf command?!? [The source and manual entry has just been submitted to comp.sources.unix, in the year, hmm... $ printf %r\\n 1988 mcmlxxxviii] -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
wietse@wzv.UUCP (Wietse Venema) (08/23/88)
In article <2848@quacky.mips.COM> dce@quacky.UUCP (David Elliott) writes: }In article <1054@marconi.SW.MCC.COM> knutson@marconi.sw.mcc.com.UUCP (Jim Knutson) writes: }>Well, one way to do it would be to use the tr command. For instance, }>to repeat your examples: } }> echo . | tr . '\007' # 0x07 } }This is a very useful trick. } }One thing it doesn't handle is generating a NUL. I've tried all }kinds of things, but have never found a way to generate a NUL It depends on what you need the null character for. For example, echo . | tr . '\200' is usually ok for output to ttys, since ordinary tty drivers strip the eigth bit (except when in raw mode, of course). -- Wietse Venema uucp: mcvax!eutrc3!wswietse | Eindhoven University of Technology bitnet: wswietse@heitue5 | 5600 MB Eindhoven, The Netherlands