Author

Topic: Linux question (Read 1177 times)

hero member
Activity: 504
Merit: 500
September 13, 2011, 11:03:32 AM
#13
PERFECT!
sr. member
Activity: 308
Merit: 251
September 13, 2011, 10:32:14 AM
#12
Code:
#!/bin/sh

ME=`whoami`

if [ "$ME" = "root" ]; then
    AMDOverdriveCtrl -i0 &
    AMDOverdriveCtrl -i3 &
    AMDOverdriveCtrl -i4 &
    AMDOverdriveCtrl -i7 &
    AMDOverdriveCtrl -i8 &
    AMDOverdriveCtrl -i11 &
    AMDOverdriveCtrl -i14 &
    cd /home/user/max &
    java -jar max.jar &
else
    sudo $0
fi

  cd /home/user/max &
    java -jar max.jar &

these 2 lines should be run in a terminal window, how would I get this to work?

EDIT: added lxterminal for a pop up screen Cheesy

Sudo is your friend Cheesy And we can make this a lot smaller !! Also I always use bash instead of sh. Just the way I learned things.

Code:
#!/bin/bash

for i in 0 3 4 7 8 11 14; do
 sudo AMDOverdriveCtrl -i$i &
done
cd /home/user/max
lxterminal -e "java -jar max.jar" &
hero member
Activity: 504
Merit: 500
September 13, 2011, 10:18:59 AM
#11
Code:
#!/bin/sh

ME=`whoami`

if [ "$ME" = "root" ]; then
    AMDOverdriveCtrl -i0 &
    AMDOverdriveCtrl -i3 &
    AMDOverdriveCtrl -i4 &
    AMDOverdriveCtrl -i7 &
    AMDOverdriveCtrl -i8 &
    AMDOverdriveCtrl -i11 &
    AMDOverdriveCtrl -i14 &
    cd /home/user/max &
    java -jar max.jar &
else
    sudo $0
fi

  cd /home/user/max &
    java -jar max.jar &

these 2 lines should be run in a terminal window, how would I get this to work?
hero member
Activity: 504
Merit: 500
September 13, 2011, 10:13:21 AM
#10
Try with this:

Code:
#!/bin/sh

ME=`whoami`

if [ "$ME" = "root" ]; then
    AMDOverdriveCtrl -i0 &
    AMDOverdriveCtrl -i3 &
    AMDOverdriveCtrl -i4 &
    AMDOverdriveCtrl -i7 &
    AMDOverdriveCtrl -i8 &
    AMDOverdriveCtrl -i11 &
    AMDOverdriveCtrl -i14 &
else
    sudo $0
fi

Make sure that the file is executable. Also make sure when you copy/paste the text to keep the backticks ` around whoami.

perfect...now I need to add 2 more lines, change the directory and then run my miner...
legendary
Activity: 1288
Merit: 1080
September 13, 2011, 10:08:47 AM
#9
i start root terminal and paste everything into there and it works, so i think i am running it as root.

So you definitely need to have you script file be run as root.   You can use the sudo command as ovidiusoft suggested, or you can chmod u+s yourfile.   It's up to you.   Configuring sudo to run a command without entering a password should be done carefully for obvious security reasons, though.
hero member
Activity: 504
Merit: 500
September 13, 2011, 10:06:05 AM
#8
i start root terminal and paste everything into there and it works, so i think i am running it as root.
legendary
Activity: 1288
Merit: 1080
September 13, 2011, 09:45:37 AM
#7
if i add that line to the top and run it, nothing changes, it starts but the fan ctrl is still not set.

When it runs without the fan, is it running as a superuser?   If not, then I guess you need whether to setuid root (or something like that, I don't know exactly), or to give the user the necessary group privilege to control the fan (though I have no idea how).

To setuid root, you need to read the chmod man page.

I think that you must run something like:

$ setuid u+s yourscript
$ chown root yourscript



sr. member
Activity: 252
Merit: 250
September 13, 2011, 09:42:58 AM
#6
Try with this:

Code:
#!/bin/sh

ME=`whoami`

if [ "$ME" = "root" ]; then
    AMDOverdriveCtrl -i0 &
    AMDOverdriveCtrl -i3 &
    AMDOverdriveCtrl -i4 &
    AMDOverdriveCtrl -i7 &
    AMDOverdriveCtrl -i8 &
    AMDOverdriveCtrl -i11 &
    AMDOverdriveCtrl -i14 &
else
    sudo $0
fi

Make sure that the file is executable. Also make sure when you copy/paste the text to keep the backticks ` around whoami.
hero member
Activity: 504
Merit: 500
September 13, 2011, 08:59:34 AM
#5
if i add that line to the top and run it, nothing changes, it starts but the fan ctrl is still not set.

I am a linux newbie, and dont really know what else to do.
legendary
Activity: 1288
Merit: 1080
September 13, 2011, 08:46:54 AM
#4
no, i do not know what that is...I am using linuxcoin.

The shebang is the first special comment line that tells what program to use.  In your case, it is probably:

Code:
#!/bin/sh

See what shell you use when you say that it's perfect when you copy/paste in your terminal.

If your code needs to run as a super-user, you might have to setuid root or something.
hero member
Activity: 504
Merit: 500
September 13, 2011, 08:43:37 AM
#3
no, i do not know what that is...I am using linuxcoin.
legendary
Activity: 1288
Merit: 1080
September 13, 2011, 08:40:20 AM
#2
i created an executable file on my desktop and this is it:

Code:
AMDOverdriveCtrl -i0 &
AMDOverdriveCtrl -i3 &
AMDOverdriveCtrl -i4 &
AMDOverdriveCtrl -i7 &
AMDOverdriveCtrl -i8 &
AMDOverdriveCtrl -i11 &
AMDOverdriveCtrl -i14 &

When I run it all starts fine without a problem, but my fans are not set. If I cut and paste this into a root terminal, all is perfect. What is the difference and why does it not run the same way? The problem is the fan ctrlis not enabled, but it is enabled when i paste it into root terminal...

You have a shebang, right?
hero member
Activity: 504
Merit: 500
September 13, 2011, 08:25:48 AM
#1
i created an executable file on my desktop and this is it:

Code:
AMDOverdriveCtrl -i0 &
AMDOverdriveCtrl -i3 &
AMDOverdriveCtrl -i4 &
AMDOverdriveCtrl -i7 &
AMDOverdriveCtrl -i8 &
AMDOverdriveCtrl -i11 &
AMDOverdriveCtrl -i14 &

When I run it all starts fine without a problem, but my fans are not set. If I cut and paste this into a root terminal, all is perfect. What is the difference and why does it not run the same way? The problem is the fan ctrlis not enabled, but it is enabled when i paste it into root terminal...

Jump to: