Tag Info

New answers tagged

0

So, I resolved this issue by recompiling weechat and upgrading from version 0.4.3 to 1.0.1. It's working like a charm now. $sudo apt-get remove weechatand from here follow the instructions in the readme that accompanies weechat from their website rather than the Ubuntu repo.


4

Below a python solution (script). The script uses the imghdr module to recognize the file type. It will add the correct file extensions (if missing), of the following types: rgb, gif, pbm, pgm, ppm, tiff, rast, xbm, jpeg, bmp, png If the file already has a file extension, it will be skipped. In case the file is of an unknown file type (if it is damaged ...


2

A one-liner using the rename command: rename 's/.*/use File::MimeInfo::Magic qw#mimetype extensions#; sprintf("%s.%s", $&, extensions(mimetype($&)))/e' * -vn it's using the Perl File::MimeInfo module to query the file (sort of how the file command does) to work out what the file is and then to append the first extension MimeInfo has for that MIME ...


1

Simple script #!/bin/bash for file in ~/path/to/images/*; do TYPE=$(file --mime-type -b "$file" | cut -f2 -d/); if [[ ! $file =~ \.$TYPE ]]; then echo mv -v "$file" "$file.$TYPE"; fi done Explanation of TYPE=$(file --mime-type -b "$file" | cut -f2 -d/); (finding file type) find the extension of each $file using file(determine file ...


0

It's invasive, but you can use the oldest debugging technique in the book: print stuff to mark where things are going wrong: sudo tee -a /etc/profile <<<'echo /etc/profile' sudo tee -a /etc/bash.bashrc <<<'echo /etc/bash.bashrc' tee -a ~/.profile <<<'echo ~/.profile' tee -a ~/.bashrc <<<'echo ~/.bashrc' tee -a ...


1

To find which commands bash runs on start-up and which file those commands came from, run: PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7>&2 The output is lengthy but the source of the gibberish will hopefully be clear. Explanation: PS4='+$BASH_SOURCE> ' When creating an execution trace, bash will prepend every line with an expansion of ...


0

This snippet would: Check on different sessions suggest to use sudo !! and return an error if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] then echo "You must be root to run this script!" echo "use 'sudo !!'" exit 1 fi


-2

You could try to type in: /bin/sh and then type in the case called: Case (shebang) in /bin/sh ./convert.sh {} sed -i find shebang bash -l /bin/sh endl it might work fine this way.


11

Your friend on another computer probably uses an OS which has /bin/sh linked to /bin/bash. In Ubuntu (actually, Debian and most Debian derivatives), /bin/sh is not linked to /bin/bash, but to /bin/dash, which doesn't support many bash-specific features, but is considerably faster. On Arch Linux: $ ls -l /bin/sh lrwxrwxrwx 1 root root 4 Sep 28 15:26 /bin/sh ...


1

Consider this script (saved as /home/muru/test.sh): #! /bin/bash DRI_PRIME=1 glxgears -info A basic launcher for this would look like (say, save it as /home/muru/test.desktop): [Desktop Entry] Type=Application Terminal=true Name=glx-gears-info Exec=/home/muru/test.sh Make them both executable: chmod +x test.sh test.desktop Now you should have these ...


1

Quick answer, try this: #!/bin/bash DRI_PRIME=1 xfce4-terminal --window -H -x glxgears -info Don't know if all the switches are needed, but it worked.


0

Generally system startup scripting stdout is directed to the console device unless it is explicitly directly elsewhere within the specific startup script.


0

Actually I just solved the problem... I'd been thinking about what if it was related to how newer drivers interact with hardware..... then I thought about my BIOS... what if something changed it? So I flashed my BIOS with a new image, and my problem went away. What puzzles me, is what could have affected my BIOS like that?


0

I tried the same desktop file definition and it works as expected for me. So double check that the launcher script has the right permissions: chmod u+x /usr/local/robomongo-0.8.4-i386/bin/robomongo.sh Alternatively you may try the following Exec command: Exec=bash /usr/local/robomongo-0.8.4-i386/bin/robomongo.sh


-1

Use this simple command For upper to lower case Where 'f' is file name where you want to do conversion. tr "A-Z" "a-z" < f For lower to upper case tr "a-z" "A-Z" < f


1

Remove the line sudo su. It starts a new root shell that never returns and that is why any command after that is not being executed. On top of that granting yourself a permission to do sudo su without password is a serious security risk and should not be done in a real world environment.


2

Move if you only need it in the target path, copy if you need it in both locations. There's no inherent "insecurity" to mv or cp, and you'll be needlessly adding complexity (and extremely likely bugs) to your scripts if you start trying to implement your own mv. For special cases there may be more suitable tools than either. For example, if you want to ...


1

It depends. In certain (usually rare) situations you should cp the file to a temporary name on the target filesystem, then mv it to it's final name, as the mv operation is autonomous on a journaled file system. If there is any chance the application will try to read this file while you are replacing it, do this. You specified that you are transferring the ...


0

Change the $cp variable to $cprice which is what you read in the line that says read cprice. echo enter selling price read sprice echo enter costprice read cprice if [ $sprice -lt $cprice ] then echo Loss else echo Profit fi The script returns Profit even if $sprice has the same value as $cprice, so to be accurate add these lines to your ...


1

You could use a script, running in the background, checking every (for example) 20 seconds if the disc is mounted. If it is, it runs an rsync job (once) to upload/update the files on the external disc. The script below is an example, and so is the suggested rsync job. use man rsync for more information on rsync. It runs the backup job one single time after ...


1

Like I mentioned in my comment, the mediainfo command is really, really slow. There are better alternatives I think. Having said that, here is my version of a python script, that should do the job (python3): #!/usr/bin/env python3 import os import subprocess directory = "/path/to/files" # list the files in the directory files_tosort = ...


0

I had a similar problem in Linux mint with LXDE, every time i started or rebooted my system the mouse pointer resets to the default even when i edited the Xorg.conf file with mouse acceleration options, it simply didn't work. What worked for me was editing the file /home/yourusername/.config/lxsession/LXDE/desktop.conf I edited the [mouse] section of the ...


1

I quickly made a python script which calls mediainfo process for each file in a search criteria and sorts then by sorting criteria and prints out the results. Modify for your own needs. This uses pure string sorting for the values. You could also add reverse=True for sorted method if wanted or do whatever you want with the code otherwise. This script ...


1

You may find it helpful to check out this thread. Here's a quick summary as suggested in the comments: 1) install python-nautilus and python-mutagen with sudo apt-get install python-nautilus python-mutagen 2) Set your PYTHONPATH variable by following the instructions here. 3) Create a directory called python-extensions in ~/.nautilus 4) Download this ...


2

git push and git pull change your files only when there are differences. if you try to git add --all when there's no changes, it won't add anything, the subsequent git commit -m "" and git push will have no effect also. the script you referred should work properly. if you want extra checks you can do git remote update then git diff to see the difference ...


1

As @Cyrus suggested, you probably have a non-printing character there that is causing you problems. The most likely reason is that at some point you edited this script from a Windows machine and a \r was added to the end of the line. You can check if anything is there on that line by running grep 'if [ "$exit"' script.sh | od -c That will show all ...


0

It took a long time for me to find one that worked for me so I made a video on how to use this function. Don't know about it creating list though XnViewMP http://www.xnview.com/en/xnviewmp/ Link to youtube video showing how it works


2

Some points that seem to be confusing you: # is the comment character. Adding it to the beginning of a line makes cron ignore that line. Don't mess with /etc/cron/hourly etc. There's no need to and they have a different format (see next point). The format of a user's crontab is minute hour day-of-month month day-of-week command The format of the files ...


2

Creating your crontab file with crontab -e is probably the best method for you, but starting your crontab lines with the # character tells the system to ignore those lines. Remove the # and leading whitespace before the 30 in your crontab line. Should just look like this: 30 * * * * /home/michael/Documents/example.sh Additionally, please ensure that cron ...


2

I believe I have an answer to my own question that leverages CameronNemo's partial solution and Mark Russell's answer to a related but somewhat different question. Two Upstart configuration files are required. The first is a job that starts as soon as the local filesystem is available, performs the desired file modifications as a pre-start script, and then ...


1

Let's assume that you often place random scripts in ~/bin as one of the comments mentioned. Just open your ~/.bashrc (provided that BASH is your shell of choice) and as the last line add: export PATH="${PATH}:~/bin" and that's pretty much it. You can add any directory to your PATH environment variable this way and it will allow you to run any executable ...


1

Try commenting out all your "exit" commands (if any) in your script by placing # in front of them and give it a go. Perhaps you are executing "exit" in your shell that closes the terminal session.


2

You're not using the $i variable inside the loop for i in "${addresses[@]}"; do # ..^ echo $addresses, disable, , , >import.csv # .......^^^ should be: echo $i, ... done For an array variable, when you print the variable without specifying an index, bash seems to give you just the first element. $ x=( one two three ) $ echo $x one


2

You can define a simple task job that start on event of your choice, run your script and at the end emit event to start the other two job. For example: # mainJob - # # This service emit myEvent to run firstJob description "emit myEvent to run firstJob" start on runlevel [2345] task console log script echo "(startTask) $UPSTART_JOB -- ...


0

"@fkraiem Most likely not. I am installing a version of ubuntu and would like to make changes automatically versus doing the same process several times for different boards" You could write a Bash script that, when run, makes the changes you want. Then you can put it on a USB stick and run it with every new install. (this is all in a terminal, I use ...


1

start on starting jobA or starting jobB instance $JOB pre-start exec /path/to/script The starting bit prevents the jobs from moving on in their life cycle until this job completes. The instance bit is so that both starting events (for jobA and jobB) are inhibited, not just one, as would be the case if you did not have an instance stanza. THe use of ...


0

I think it's a perl version issue, check what perl version did you use previously to run that script. What I'm sure about is that Ubuntu installs the latest stable version of every software. Take for example if you have a python3 script that runs on ubuntu 12.04 it might not work on ubuntu 14.04, and the reason for that is the firs has python 3.2, when the ...


0

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 This was a bug in LWP (CVE-2014-3230) which was fixed in newer versions. PERL_LWP_SSL_VERIFY_HOSTNAME is only used to omit verifying the hostname in the certificate, not the certificate chain. But, because you are using a self-signed certificate chain verification will fail. This option was only introduced for ...


1

The installation instructions aren't telling you to run run bin/jason.sh. They're saying to run bin/jason.sh. Suppose you wanted to put the Jason folder in your home folder: cd # changes to your home folder # change URL for different version or different mirror wget http://superb-dca3.dl.sourceforge.net/project/jason/jason/version%201.4.1/Jason-1.4.1.tgz ...


0

After decompressing the Jason archive, the command to type is bin/jason.sh NOT run bin/jason.sh: sylvain@sylvain-ThinkPad-T430s:~/Downloads/Jason-1.4.1$ chmod +x bin/jason.sh sylvain@sylvain-ThinkPad-T430s:~/Downloads/Jason-1.4.1$ bash bin/jason.sh JDK_HOME is not properly set! sylvain@sylvain-ThinkPad-T430s:~/Downloads/Jason-1.4.1$


1

cp: cannot stat ‘/GNI’: No such file or directory That's because of the whitespace: cp reads it like this: cp -ra /home/michael/Documents/GeneralNetwork /GNI That the folder: /home/michael/Documents/GeneralNetwork needs to be copied to /GNI. But there is no folder in /GNI, therefore the error. If there is a whitespace between files, put it ...


0

A few things... 30 22 * * 0 means every Sunday at 10:22pm. Not daily. Use a * in the fifth time field if you want every day of the week. Files in /etc/cron.d/ take a slightly different format. The second argument (after the time string) sets the user it will run as. To do things this way your file should read: 30 22 * * * root apt-get update && ...


1

You can use find along with exec for this propose. Your install.sh should be #!/bin/bash find ./apps -type d -exec echo Entering into {} and installing packages \; replace text after -exec with your command for example #!/bin/bash find ./apps -type d -exec touch {}/test.txt \; It will loop through app and all its sub-directories and will create ...


2

Use full path of your parent directory(in my case apps directory located in my home directory) and remove one extra command(cd ..) for f in ~/apps/*; do [ -d $f ] && cd "$f" && echo Entering into $f and installing packages done; See screenshot: with cd .. command and using apps/* See screenshot: without cd .. command and using ...


2

You could use the functions provided by the lsb-base package in /lib/lsb/init-functions. I have seen init.d scripts sourcing that file and then using the functions within, such as log_end_msg: $ (. /lib/lsb/init-functions; log_end_msg 1) ...fail! $ (. /lib/lsb/init-functions; log_end_msg 0) ...done. For example, a snippet from /etc/init.d/ssh (case ...


2

I think the functions you are looking for are sourced from /lib/lsb/init-functions, and named log_success_msg and log_failure_msg: $ . /lib/lsb/init-functions $ log_success_msg foo * foo $ log_failure_msg foo * foo In this output, the first * is grey, the second is red (error case). Not extremely colorful, just enoug to get the point across... From ...


2

The Problem Using sudo inside a script often doesn't do what you expect (see Digital Chris' link: “How do I run this sudo command inside a script?”). Sending sudo to the background will not work (correctly and reliably), if you need to provide a password. The Solution Retrieve the process ID inside the process spawned by sudo. If you use exec, you don't ...


0

Guessing... If each command works independently, it could be that the PROCESSID assignment happens too quickly. Try adding 'sleep 3s' after 'sudo ...' and see what happens.


0

The problem is that script sections in upstart are run with the set -e flag. This means the shell with exit if any command errors (like pgrep). THe solution is to add a || true after the pgrep command.


1

Remove Spaces between variable and its value. USER='user' PASS='password' FILE='path/filename.txt' Assignment in bash scripts cannot have spaces around the = For more understand = also is compare operator. see this example: if [ "$a" = "$b" ] Note the whitespace framing the =. In this case we are comparing "$a" and "$b". if [ "$a"="$b" ] is not ...



Top 50 recent answers are included