[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 981: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead
Tynsoe Projects • View topic - 2 "commands" in one line...?

2 "commands" in one line...?

2 "commands" in one line...?

Postby rudeboy » Thu May 13, 2010 7:05 pm

how do i do that... my code:

uptime | awk '{print "Uptime : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}' } and {" who | awk '{ print $1 }'|uniq|sort "}
df -h | grep disk0s2 | awk '{print "Mac HD:", $2, "total,", $3, "used,", $4, "remaining"}'
echo Battery: `pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p'` - Time: `osascript /Users/roeiboot/bin/battery_time.scpt`
echo External IP: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/ :]//g'`


talking about the code in red, i want it to display "Uptime: x:xx, x user (username)

all works, except username..

thanks in advance.

(ps. it's a bunch of code i found all over the web, if something can/should be improved let me know as well plz...
rudeboy
 
Posts: 18
Joined: Sun May 09, 2010 3:33 pm

Re: 2 "commands" in one line...?

Postby ybizeul » Thu May 13, 2010 8:19 pm

You have specific style in the forum to format code : I can't copy & paste that code to test it.

What's that "and", this is not shell afaik, try puttin something that works here I'll try to complete :-)
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm

Re: 2 "commands" in one line...?

Postby rudeboy » Thu May 13, 2010 8:27 pm

uhm, everything but the red works, oh i see.... yea i had used the [ code ] tags but i could make the line that didn't work red :]

here's the code again:

Code: Select all
uptime | awk '{print "Uptime : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ &amp;&amp; NR &gt; 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}' 'who | awk '{ print $1 }'|uniq|sort'
df -h | grep disk0s2 | awk '{print "Mac HD:", $2, "total,", $3, "used,", $4, "remaining"}'
echo Battery: `pmset -g ps  |  sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p'` - Time: `osascript /Users/roeiboot/bin/battery_time.scpt`
echo External IP: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/ :]//g'`


thanks.
rudeboy
 
Posts: 18
Joined: Sun May 09, 2010 3:33 pm

Re: 2 "commands" in one line...?

Postby ybizeul » Fri May 14, 2010 7:44 am

I don't see very well what you are trying to accomplish.

Are you aware that you can test these lines in Terminal application ? If there is a syntax error, then it will be wrong in GeekTool too.

The "&amp;&amp;" part looks weird to me, and I think should be replaced by "&&", same thing for "&gt;" hat should be replaced by ">"
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm

Re: 2 "commands" in one line...?

Postby rudeboy » Fri May 14, 2010 1:09 pm

the Uptime line shows this: "Uptime : x:xx, x,"
i want it to show: "Uptime : x:xx, x, <username>"

so add the username currently logged in.

the &amp; and &gt; was like that when i copied the code, and yea they "translate" in what you say, a & and >.... i can change them even thought that part of the code works.

(ps. yes i know i can run those line in Terminal...)

Thanks.!
rudeboy
 
Posts: 18
Joined: Sun May 09, 2010 3:33 pm

Re: 2 "commands" in one line...?

Postby ybizeul » Sat May 15, 2010 8:08 pm

What I do not get is : the code does not work, right ? Even without username ?

To answer your question about two command on a single line, you can clean up the code a bit and assign values to variables, something like this does work :
Code: Select all
LINE1=`uptime`;LINE2=`who`;echo $LINE1 $LINE2
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm

Re: 2 "commands" in one line...?

Postby rudeboy » Sun May 16, 2010 3:29 am

without the username included the code does work..

i will give your suggestion a try, tks.
rudeboy
 
Posts: 18
Joined: Sun May 09, 2010 3:33 pm

Re: 2 "commands" in one line...?

Postby ybizeul » Sun May 16, 2010 7:07 am

What does work ? Certainly not
Code: Select all
uptime | awk '{print "Uptime : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ &amp;&amp; NR &gt; 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm

Re: 2 "commands" in one line...?

Postby rudeboy » Mon May 17, 2010 2:37 am

uhm, how do i prove it works on my MacBook ? :]
rudeboy
 
Posts: 18
Joined: Sun May 09, 2010 3:33 pm

Re: 2 "commands" in one line...?

Postby ybizeul » Mon May 17, 2010 5:32 am

Copy and paste the output of that command, including the command, and its full result, from Terminal application :-)
ybizeul
Site Admin
 
Posts: 133
Joined: Fri Jan 22, 2010 4:34 pm


Return to GeekTool

Who is online

Users browsing this forum: No registered users and 3 guests

cron