run script error
I have a script as below
Code:
if [[ ... ]] ; then Now , I wold like to run the command "top" in background , it changed the script to as below , it pops the error "top: failed tty get" , would advise what is wrong , how to fix it . thanks . Code:
if [[ ... ]] ; then |
Well the error message appears to be quite clear on the problem, ie. you are trying to run top without a tty attached.
I guess the real question would be why you would want to run it in the background?? I am also not quite sure on the point of '...' as a test, but as it always seems to be true what is the point of the if at all? |
you ought to try xterm -e top & (or choose your favorite terminal emulator)
|
Quote:
when run it , it pops the below error , would advise how to fix it ? Code:
Warning: This program is an suid-root program or is being run by the root user. thanks |
so that means there is no X environment available - or you have not set that DISPLAY variable (probably you only need to set it). top needs a terminal to work properly.
From the other hand you need to provide more information, it is not really enough to give any hints |
Quote:
set that DISPLAY variable <<== would advise how to do it ? besides , what infomation that I need to provide ? thanks |
if you have no idea what is that probably you won't need that.
Do you have graphical environment or just command line? what do you want to achieve at all? |
Quote:
just for testing only , we will implement another program later , would you help me for providing suggestion about how to do it , may be I may explain what my project target is . |
Maybe you could start by explaining why you picked top? Does it have similarities the 'other' program?
|
Quote:
|
> may be I may explain what my project target is.
Quite an idea. I, for one, am not a clairvoyant. |
thanks reply ,
what I just want is use the process of running the command "top" in background to eating up system resource , this is only testing purpose , is there any way to make it work ? thanks |
Not sure about the others, but that didn't really clear anything up for me :(
Again, why does it need to be top? If you want to eat all your system resources (not sure why you would want to on purpose), just create a recursive loop to call itself forever. |
Quote:
"just create a recursive loop to call itself forever" << I am trying to do that but fail , as above the script , it pops error when run it , would advise how to modify it ? thanks |
Here try this:
Code:
#!/bin/sh I was nice and put a limit so that it will not (necessarily) run until your system melts down, but you will need to adjust it depending on your system resources and how much you want to waste them. Save this to a script named resource_killer.sh, make it executable (chmod +x resource_killer.sh) then run it in the background with ./resource_killer.sh &. It will consume CPU and memory resources until there are no more... Offered as a complete freebie in order to facilitate having this thread marked as SOLVED. |
All times are GMT -5. The time now is 08:21 AM. |