Tag Info

New answers tagged

0

See the corrected script: #!/bin/bash ## the driver's name drivername=$(lspci -vv -s $(lspci |grep -i ethernet| awk -F" " '{print $1}')| awk -F" " '/driver/ {print $5}') checkout () { lsmod > tmp.txt if grep -i $drivername "tmp.txt" > /dev/null ; then echo "there's a driver called: $drivername" exit 0 else echo ...


1

It tests whether the file "/etc/debian_version" exists and is a regular file.


0

Turns out installto.sh is not a linux shell script, though it ends with .sh. It is a PHP file that is meant to be run from the command line. To successfully upgrade Roundcube, it needs to be executed as follows: $ cd roundcubemail-1.0.5 && sudo php bin/installto.sh /var/www/html/roundcube My mistake was I was trying to run the script using bash ...


0

Tilde isn't expanded in quotes (single or double). You have three options: remove the quotes: string="~/hello" -> string=~/hello (vulnerable to whitespace) use command substitution: string="~/hello" -> string="$(echo ~/hello)" (less vulnerable) as suggested by @steeldriver, use the HOME environment variable: string="~/hello" -> string="$HOME/hello"


1

The tilde is not expanded when in quotes -- ref: https://www.gnu.org/software/bash/manual/bashref.html#Tilde-Expansion So you want to remove the quotes: str_getIdle_exe=~/Documents/Seb/Prjcts/Idle/getidle/src/getIdle If the path under your homedir contains a space, just leave the tilde unquoted: some_path=~/"dir with spaces/file with spaces"


0

#!/bin/bash ps -e -o pid,pmem | awk '{ if($1>100) s+=$2} END {print s}'


0

The two answers I've liked best to solve this are using expect and this one where they recommend using the --init-file flag either in the shebang or when executing the terminal: #!/bin/bash --init-file commands to run ... and execute it as: xterm -e /path/to/script # or gnome-terminal -e /path/to/script # or the-terminal -e bash --init-file ...


1

You found a bug in the Bash Completion library used by Ubuntu. What does this mean? Ubuntu uses a bash completion library to make bash completion smart. This library lives in /usr/share/bash-completion/bash_completion. Essentially, this library declares a few clever functions that know about typical commands and how to complete them. Whenever you press ...


0

Write a shell script that initiates your Python script and add that SHELL script in start-up program list for starting it automatically every time you reboot. Shell Script: Execute a python program from within a shell script. One more helpful Link : How to run the Python program in the background in Ubuntu machine? To run it every time on reboot : How to ...


1

You're running your installation script with sudo but gsettings are a per user configuration system. that's why you're no seeing any change. Try without sudo (as a normal user) and it should work.


1

Try adding an ampersand at the end of the lines to put processes into background. #!/bin/bash gnome-terminal -x /bin/bash haguichi -d & cd /home/reed/StarMade gnome-terminal -x java -jar StarMade.jar -force & gnome-terminal -x ./StarMade-dedicated-server-linux.sh &


4

You could just take out the interactive stuff and copy the lines to /etc/rc.local between the # By default this script does nothing. and the exit 0 lines sudo nano /etc/rc.local Insert the edited script.. cd /sys/devices/platform/applesmc.768/ echo "Enabling manual override for Fan 1 (ODD fan)..." echo '1' > fan1_manual echo "Setting speed of Fan 1 ...


3

Your script halts because sudo su starts a new shell process. Your original shell process - the one that is running your script - is waiting for the sub-shell to end. I propose to run whole script with root privileges instead of asking to log in as root from script itself. Remove sudo su part from your code and run script like that: $ sudo ./yourscript ...


0

The command sudo su creates a new shell session. It is waiting for you to type your commands. It is NOT going to execute the commands after that line. You have 2 options: 1) Extract the commands after sudo su in a separate script and run that with sudo 2) change the lines like echo '1' > fan1_manual to echo '1' | sudo tee fan1_manual


1

Definitely more verbose, a python option: #!/usr/bin/env python3 import subprocess import os #--------------------------- directory = '/path/to/images' m_subject = 'image' #--------------------------- def get(command): return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8") total_size = [] for root, dirs, files in ...


1

The following isn't perfect. It doesn't handle directories with spaces well but unless you have a load of header directories with identical suffixes, that's not really an issue. find -type f -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -printf '%h %s\n' \ | awk -F '[ /]' '{a[$2] += $NF} END{for(i in a){print i, a[i]}}'


1

Simplest solution: printf %.2f $(echo "$float/1.18" | bc -l)


7

You are forgetting to supply a mandatory argument. Usage: eui_install.py [ZIPFILE] means you have to include a name of a zipfile. The command is: python eui_install.py zipfile where zipfile is a file name you need to supply (probably the mod you want to edit looking at the script). The files in the designated folder still have names with ...


2

The directory ~/bin ~/bin is simply a folder named "bin" in your personal home directory. "~" stands for your home directory, so ~/bin is actually: /home/<yourname>/bin. You probably still have to create the folder. You can do that just like you make any other folder, and move the executable into that folder (make sure the file is executable). ...


0

The software is designed to run only on a custom Linux built for it, so there is no way to install it on Ubuntu.


2

Final script that worked. in chat #!/bin/bash service=hhvm if ! (($(ps -ef | grep -v "grep"| grep "$service" | wc -l))) ; then echo "starting $service" service hhvm start else echo "$service is running" fi


2

foo=3 if [[ $foo -eq 0 ]]; then # -eq: equal echo "foo equals 0" else echo "foo is not equal to 0" fi


2

In addition to the previous answers, even if /bin/sh is a symbolic link to /bin/bash, #!/bin/sh is not totally equivalent to #!/bin/bash. From the bash(1) man page : "If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well." For ...


1

top -b -n1 | grep Cpu | sed -r 's@.+:\s([0-9\.]+).+@\1@' As has already been said the option -b together with -n 1 will give a single text output from top rather than the constantly updating default. Then you can pipe to sed to find the value you are looking for.


1

As you can read here - http://sernaonubuntu.wikidot.com/command-line:piping-and-directing-output the >> symbol appends the result of the command to the file The result of 'nameserver XXX.XXX.XXX.XXX' command is.. well command not found :P What comes to the rescue is the echo command (as @chaos rightfully said) which echoes the text and that result can be ...


-3

Have you tryed this in sted type in this: #!bin/sh Case (nameserver) in /bin/sh nameserver = XXX.XXX.XXX XXX > gksudo nameserver /etc/resolv.conf XXX.XXX.XXX.XXX > endl and it might work fine this way.


3

You were very close, try that: #!/bin/sh gksudo "bash -c \"echo 'nameserver XXX.XXX.XXX.XXX' >> /etc/resolv.conf\""


0

Per the documentation: http://wiki.qemu.org/download/qemu-doc.html#host_005fdrives You should just be able to do -hda /dev/sdX But, since this is Windows, you basically just took your hard drive out of your computer and inserted it into another. So it'll go and have to find new hardware etc. You might seriously mess up your Windows disk in the ...


9

In one sentence: it doesn't work because you aren't calling it correctly. First, since your script doesn't start with #!/bin/bash, it isn't actually a bash script. Which shell it is executed by depends on how you invoke it. When you invoke it from the bash command line, bash forks a new instance of itself (this has to happen to execute any external command ...


2

Edit: It seems that there still seem to be some problems on certain machines that run this script. Another (and perhaps the best) way of doing this would no be attempting to use a shell builtin, but rather directly modifying the $HISTFILE #!/bin/bash HISTFILE=~/.bash_history # Or just let the shell decide for x in `seq $1 $2` do sed "\'$1d\'" $HISTFILE ...


0

This is how I made the "Steam button" work on my ASUS ROG G751. I would not be surprised if there is a simpler way to do this :) I am using xbindkeys to bind the steam key to a script. The script will start steam if it is not already running. If steam is running the script will change focus to steam. To achieve this I am using xdotool. Install xbindkeys: ...


2

In the while condition you can test whether exit status of xterm was successful or not with something like this: result=1 while [ $result -ne 0 ]; do xterm result=$? done $? variable holds exit status of last executed command.


10

Try this: while true; do xterm && break; done Applications have exit status codes so that if something exits fine it returns zero... And if something went wrong, it throws out another number. This allows people to hook in and find out the exact issue. This is what the other answer is doing. && just checks that the previous command was a ...


1

From the xinput man page: device can be the device name as a string or the XID of the device. It means that you can just give the full name of your mouse to the xinput command. Let's first identify your mouse device, type xinput in a terminal: $ xinput ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST ...


0

You can set a cronjob for your user only and it will not require your root password. $ crontab -e


1

I found out that crontab is probably one of the options, but I is it "safe". Why this command require the root password and so on? Why would requiring a password make something less safe? Using crontab is safe since nobody can change those files unless they know your admin password. Or Is there any other options (better, simpler and so on) how to ...


2

Let us say the old_word marker is known. We can then use grep to obtain the number from the original file: NUM=$(grep -Po -m1 '(?<=old_word )\d+' FILE) This uses Perl regular expressions. It says that old_world should precede some digits, but should not be considered part of the actual match. -o -m1 tells grep to print only the matched section (the ...


4

With "Parameter Expansion": origPath="/home/django_auth_lifecycle/urls.py" path="${origPath//\//\\}" echo $path Output: \home\django_auth_lifecycle\urls.py With a pipe, sed and "Command Substitution": origPath="/home/django_auth_lifecycle/urls.py" path="$(echo "${origPath}" | sed -e 's/\//\\/g')" echo $path Output: ...


0

I changed the setxbmap gh fula to setxbmap us and that fixed my keyboard. Yeah it seems that I got a modified version rather than the github one. The encryption nonsense first happened when I tried to modify the characters from the Japanese symbols to English letters, and numbers but after I deleted the .swp file I never saw that nonsense again(maybe I ...


1

The setxkbmap command is your problem - try setxkbmap gb (or us, or whatever..) to reset; you're currently in whatever gh fula represents!


2

Section Parameter Expansion (extract) from bash's manpage: ${parameter,,pattern} Case modification. This expansion modifies the case of alphabetic characters in parameter. The pattern is expanded to produce a pattern just as in pathname expansion. The ^ operator converts lowercase letters matching ...


2

If you're willing to run another untrusted sudo command: sudo sed -i '/^export MOZ_USE_OMTC=1$/d' /etc/X11/Xsession.d/90environment You have appended a line containing export MOZ_USE_OMTC=1 to the file /etc/X11/Xsession.d/90environment. This sed command deletes any line which contains exactly that. Or you could open the file in nano to edit it manually: ...


1

Similar to edwin's answer, but with improved portability for posix & ksh, and a touch less noisy than Richard's: substring=ab string=abc if [ "$string" != "${string%$substring*}" ]; then echo "$substring IS in $string" else echo "$substring is NOT in $string" fi string=bcd if [ "$string" != "${string%$substring*}" ]; then echo "$string ...


1

After a few days of trial and error I found the answer to my question. I decided to post my solution to my question because it might help someone who is experiencing the same problem. Here are the steps that I followed. Open the terminal crt+alt+t Type gedit ~/.local/share/applications/mimeapps.list Under [Added Associations] list add ...


0

If you are using Unity, and use indicator-keyboard to change the keyboard input, then in 14.04 at least we can exploit the fact that this changes the GSettings key org.gnome.desktop.input-sources.current. Here is a Python script that listens for changes to that key and then calls a function that prints some information and execs a subprocess. from ...


0

( echo "To: example@gmail.com" echo "From: system <root>" echo "Subject: Rails Energy Valut Failure on `hostname` (`hostname --ip-address`) - `date` server restart" ) 2>&1 | /usr/lib/sendmail -t


0

Nope. One of the big downsides to the old code page system is that there is no way to detect which one is being used; you must simply know that a priori. If you do know which files are using which encoding then you can convert the names using something like: mv somefile `echo somefile | iconv -f CP1251 -t UTF-8`


0

Use convmv, a CLI tool that converts the file name between different encodings. To convert from (-f) these encondings to (-t) UTF-8 do the following: convmv -f CP1251 -t UTF-8 inputfile convmv -f KOI-8 -t UTF-8 inputfile convmv -f ASCII -t UTF-8 inputfile In addition, if you want to convert the file content, use iconv, a CLI tool to convert file content ...


0

I have managed to duplicate your problem and have a solution. As your research has told you, your original problem was having: Terminal=true together with: Exec=lxterminal -e /bin/hello.sh The only problem is, that when you use: Terminal=false the terminal closes after executing the script, though it does actually run your script. As your script ...


0

you can try this way: [Desktop Entry] Version=1.0 Type=Application Hidden=false NoDisplay=false Terminal=false Encoding=UTF-8 Exec=xfce4-terminal -x /usr/local/robomongo-0.8.4-i386/bin/robomongo.sh Icon=/usr/local/robomongo-0.8.4-i386/share/icons/robomongo.png Name=Robomongo Comment=Launch Robomongo and give the read permission with sudo chmod +x ...



Top 50 recent answers are included