Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!

Ogłoszenie

Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

#1  2013-08-29 14:25:29

  spook - Użytkownik

spook
Użytkownik
Zarejestrowany: 2013-03-26

[SOLVED]echo- wyświetlanie wyniku polecenia zachowując znaczniki ENTER

Witam
Problem uwidocznię na przykładzie:
wynik polecenia

Kod:

~$ sh -c sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +46.0°C  (high = +74.0°C, crit = +100.0°C)
Core 1:       +44.0°C  (high = +74.0°C, crit = +100.0°C)

w83627dhg-isa-0290
Adapter: ISA adapter
Vcore:        +1.15 V  (min =  +0.00 V, max =  +1.74 V)
in1:          +1.86 V  (min =  +1.02 V, max =  +0.38 V)  ALARM
AVCC:         +3.22 V  (min =  +2.21 V, max =  +0.45 V)  ALARM
+3.3V:        +3.22 V  (min =  +2.40 V, max =  +1.02 V)  ALARM
in4:          +1.63 V  (min =  +0.05 V, max =  +0.43 V)  ALARM
in5:          +1.58 V  (min =  +1.34 V, max =  +0.11 V)  ALARM
in6:          +1.61 V  (min =  +1.06 V, max =  +1.50 V)  ALARM
3VSB:         +3.22 V  (min =  +1.54 V, max =  +1.31 V)  ALARM
Vbat:         +3.06 V  (min =  +2.26 V, max =  +1.60 V)  ALARM
fan1:           0 RPM  (min = 5273 RPM, div = 128)  ALARM
fan2:         551 RPM  (min = 84375 RPM, div = 16)  ALARM
fan3:           0 RPM  (min = 10546 RPM, div = 128)  ALARM
fan5:           0 RPM  (min = 10546 RPM, div = 128)  ALARM
temp1:        +42.0°C  (high = +55.0°C, hyst = +106.0°C)  sensor = thermistor
temp2:        +10.0°C  (high = +120.0°C, hyst = +115.0°C)  sensor = CPU diode
temp3:         +2.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
cpu0_vid:    +0.000 V
intrusion0:  ALARM

Kod:

~$ echo $(sh -c sensors)
coretemp-isa-0000 Adapter: ISA adapter Core 0: +45.0°C (high = +74.0°C, crit = +100.0°C) Core 1: +44.0°C (high = +74.0°C, crit = +100.0°C) w83627dhg-isa-0290 Adapter: ISA adapter Vcore: +1.15 V (min = +0.00 V, max = +1.74 V) in1: +1.86 V (min = +1.02 V, max = +0.38 V) ALARM AVCC: +3.22 V (min = +2.21 V, max = +0.45 V) ALARM +3.3V: +3.22 V (min = +2.40 V, max = +1.02 V) ALARM in4: +1.63 V (min = +0.05 V, max = +0.43 V) ALARM in5: +1.58 V (min = +1.34 V, max = +0.11 V) ALARM in6: +1.61 V (min = +1.06 V, max = +1.50 V) ALARM 3VSB: +3.22 V (min = +1.54 V, max = +1.31 V) ALARM Vbat: +3.06 V (min = +2.26 V, max = +1.60 V) ALARM fan1: 0 RPM (min = 5273 RPM, div = 128) ALARM fan2: 551 RPM (min = 84375 RPM, div = 16) ALARM fan3: 0 RPM (min = 10546 RPM, div = 128) ALARM fan5: 0 RPM (min = 10546 RPM, div = 128) ALARM temp1: +42.0°C (high = +55.0°C, hyst = +106.0°C) sensor = thermistor temp2: +10.0°C (high = +120.0°C, hyst = +115.0°C) sensor = CPU diode temp3: +2.5°C (high = +80.0°C, hyst = +75.0°C) sensor = thermistor cpu0_vid: +0.000 V intrusion0: ALARM

W jaki sposób wyświetlić wynik polecenia przy pomocy echo, tak by znaczniki ENTER nie były zamieniane na spacje?

Ostatnio edytowany przez spook (2013-08-29 18:11:05)

Offline

 

#2  2013-08-29 17:27:12

  megabajt - Użytkownik

megabajt
Użytkownik
Skąd: Wrocław
Zarejestrowany: 2012-03-07

Re: [SOLVED]echo- wyświetlanie wyniku polecenia zachowując znaczniki ENTER

echo "$(sh -c sensors)"

Offline

 

#3  2013-08-29 18:08:22

  spook - Użytkownik

spook
Użytkownik
Zarejestrowany: 2013-03-26

Re: [SOLVED]echo- wyświetlanie wyniku polecenia zachowując znaczniki ENTER

[b]megabajt [/b]

Kod:

echo "$(sh -c sensors)"

[/quote]
Dokładnie tak:) próbowałem wcześniej użyć nawiasów, lecz zapomniałem o cudzysłowie.

można jeszcze tak

Kod:

echo "`sh -c sensors`"

[url]http://superuser.com/questions/189362/how-to-pipe-command-output-to-other-commands[/url]

Offline

 

Stopka forum

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson
To nie jest tylko forum, to nasza mała ojczyzna ;-)

[ Generated in 0.009 seconds, 14 queries executed ]

Informacje debugowania

Time (s) Query
0.00011 SET CHARSET latin2
0.00004 SET NAMES latin2
0.00108 SELECT u.*, g.*, o.logged FROM punbb_users AS u INNER JOIN punbb_groups AS g ON u.group_id=g.g_id LEFT JOIN punbb_online AS o ON o.ident='3.135.184.195' WHERE u.id=1
0.00063 REPLACE INTO punbb_online (user_id, ident, logged) VALUES(1, '3.135.184.195', 1732909642)
0.00037 SELECT * FROM punbb_online WHERE logged<1732909342
0.00063 DELETE FROM punbb_online WHERE ident='18.119.109.101'
0.00081 DELETE FROM punbb_online WHERE ident='3.138.105.4'
0.00070 DELETE FROM punbb_online WHERE ident='52.167.144.197'
0.00073 SELECT topic_id FROM punbb_posts WHERE id=239683
0.00005 SELECT id FROM punbb_posts WHERE topic_id=24157 ORDER BY posted
0.00054 SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM punbb_topics AS t INNER JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=24157 AND t.moved_to IS NULL
0.00006 SELECT search_for, replace_with FROM punbb_censoring
0.00082 SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM punbb_posts AS p INNER JOIN punbb_users AS u ON u.id=p.poster_id INNER JOIN punbb_groups AS g ON g.g_id=u.group_id LEFT JOIN punbb_online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=24157 ORDER BY p.id LIMIT 0,25
0.00082 UPDATE punbb_topics SET num_views=num_views+1 WHERE id=24157
Total query time: 0.00739 s