New answers tagged

3

-- is commonly used to indicate end of options, in this case perl -- file.pl -ARGUMENT This is explained in the documentation A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments.


3

Moving the mouse to a defined (absolute) position ..is simply done by the command (e.g.): xdotool mousemove 200 200 To move the mouse to the centre of the screen however is a relative command, for which we need to read the screen's information and do some calculations. This is done in the two small scripts below. Straightforward version (move cursor to ...


1

Ah, now I undersand! That's a fairly common request: All you need is to test for the existence of a given file, not its content. E.g. if you want to run the cron job, create a file say in yr home directory: $ touch /home/you/cronjob_enable. Then edit yr user crontab: $ crontab -e */5 * * * * /bin/bash -c 'test -e /home/you/cronjob_enable && /home/...


0

one possible approach would be: Create the script with just root acces (for safety sake) sudo su sudo echo 'echo "Hello world, I am `whoami`" > /tmp/test' > /path/to/script.sh sudo chmod 700 /path/to/script.sh Then change the sudoers file (according to mutliple tutorials everywhere) sudo visudo insert the following line at the end youruser ...


7

To find all files in the home directory with jpg, jpeg, png, or gif extensions and copy them to ~/backup, try: cd find . -regex '.*\(jpg\|jpeg\|png\|gif\)' \! -path './backup/*' -exec echo cp -t backup {} + How it works cd This makes the home directory, ~/, be the same as the current directory, ./. find . Look for files in the current directory -regex ...


0

Had the same error. Try easy_install hashlib


0

A one time fix would be to write a small executable program that runs your script, and assign an unique launcher icon to the executable.


3

Scandalously dirty, but perfectly working ...is the script below. I tested it to run firefox, opening the AsUbuntu site, then automatically press the link to open my profile page. Since your password is stored in your browser, in your case pressing the button is sufficient to log in. How it works in practice 15 seconds after login (your Ubuntu user ...


0

One available option is to use saltstack to execute the same command on each minion. After adding salt to each computer you can run the same command on each machine with something like salt '*' cmd.exec_code python 'import sys; print sys.version' If you are using blender's network render addon then you could also configure a blend file to have network ...


1

I know of exactly what you are looking for, and how to use it! Run: git clone git://github.com/GM-Script-Writer-62850/Ubuntu-Mainline-Kernel-Updater bash Ubuntu-Mainline-Kernel-Updater/install Then run for the latest: KernelUpdateChecker -no-rc -v 4.6.3 -r yakkety /tmp/kernel-update And follow the prompts! Or for the latest Xenial: ...


1

You can't kill a Zombie, its already dead. It is just talking an entry in the process table before the parent process do wait(2) to read it's exit status. On a different note, to kill the parent process of any process (including Zombie), you can easily use a combination of commands ps and kill: ps -p <pid> -o ppid= will give use the PPID (Parent ...


1

According to https://www.dropbox.com/en/help/246, I suggest adding Dropbox's APT repository to your /etc/apt/sources.list by running: sudo add-apt-repository "deb http://linux.dropbox.com/ubuntu xenial main" Then, import Dropbox's GPG keys using: sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E


2

Here's one way: #!/bin/bash mydate=$(date '+%Y-%m-%d %H:%M:%S') myip=$(curl http://checkip.amazonaws.com?newline -s) printf '%s %s\n' "$mydate" "$myip" >> /home/test_a5gh/Pub_IP.txt FYI, you don't need sudo to chmod files you own in your own home directory.


0

Since you are using linux it's very easy, in linux a packet is represented by structure sk_buff. You can use netfilter framework with pre-routing hook,to mangle packet by using it's protocol and destnation port number. See the netfilter framework documentation .


0

in terminal type "chmod +x filepath". This will convert your sh file to an executable file that will run when you open it


1

As the STDOUT stream is block buffered by default (when not going to terminal) by python, you need to make the stream unbuffered (or line buffered). python provides a way to make the streams unbuffered, here is the Pythonic way: python -u foo.py So, your whole command line becomes: python -u foo.py | ~/timestamp.sh >> ~/logs/foo.log From man ...


1

The root cause is your process, here python, is using libc stdout where the output is line buffered when output to a terminal but block buffered when output to something else, like a pipe here. You can fix the issue either in the python code by explicitly flushing the buffer after each log output: sys.stdout.flush() or by controlling how buffering will ...


0

Managed to get the script running properly using netcat's nc's exit status, while running it without -v option. Anyway, it seems that netcat's netcat's output doesn't get piped into grep. I suppose it might be caused by some sort of forking. UPDATE: As terdon mentioned in a comment to his answer, part of output from nc / netcat is printed to stderr, part ...


0

Serg's script seemed to work at first. However after some time, the percentage was being evaluated incorrectly especially after coming back from hibernation. It may have been some issues with qdbus but the brightness level won't just change. So, I decided to hardcode the brightness level using the value from max_brightness file. Here's my /usr/local/bin/auto-...


1

Run the following: mv /home/folder1/test123 /home/folder1/test456


2

If you want to append successive outputs of a command substitution to an array in bash, you can use a syntax like arr+=( "$(command args)" ) For example, give files with $ grep -H 'versionName' thing* thing1:versionName: foo thing2:versionName: bar thing3:versionName: baz thing4:versionName: boo then $ for f in thing*; do version+=( "$(grep '...


1

Another not answer but solution. I use quicklists to create launchers for my most commonly used terminal sessions, i then make profiles for each one in gnome-terminal to do things like change their colours, this makes it really easy to know which server you are using. You can do this by editing your gnome-terminal.desktop file in ~/.local/share/...


2

Why it doesn't work like you do As mentioned in the comment, an application in principle can only be represented by one icon in the launcher at a time. This has always been the case. What you are referring to is probably that Unity has become "smarter" in determining which of the .desktop files is the best representative for the application's window. ...


0

find ./dirc/* -mtime +x -type f -delete ./dirc/* : is your directory (Path) -mtime +x : older than x days -type f : only files -delete : no surprise. Remove it to test before like rm Auto delete files older than 7 days


4

The problem has nothing to do with nc or netcat or any of their ilk. You are running two commands here, nc and grep, but only redirecting the output of grep. What you want to do is: nc -zv 1.2.3.4 55 &>/dev/null That, of course, would be pointless since if there's no output, you can't grep. That's what grep's -q flag is for: -q, --quiet, --...


1

I'm using another solution: echo '$var = <string> 1.11 </string>' | awk -F'> | <' '{print $1,$3}' What I did was defining > and < as delimiters and printing certain fields between the delimiters.


0

Bash has also its own regular expressions. However, they are not so powerful as in sed. The following code does the magic without calling external programs: var="<string> 1.11 </string>" first=${var#<*>} second=${first%<*>} #echo $first echo $second I tried to do it in one step too, but didn't succeed because bash regular ...


2

Intro The script below allows remembering brightness levels depending on the power source used by a laptop. It defaults to 50% on battery, 90% on AC. Overview of options and usage source_monitor.sh [-a INT] [-b INT] [-v] [-h] -a set initial brightness on AC adapter -b set initial brightness on batter -v enable verbose output -h prints this help text ...


1

Depends on the design of your shell. Does it follow the POSIX standard? If Yes, then your shell needs to read the ENV environment variable at start of any interactive session and read/execute the content of the file(s) the ENV variable refers. No other file needs to be read as per the standard. This is a bare minimum for POSIX conformation as far as ...


3

The profile file is always run by login shell, and if you want other scripts to be sourced by the login shell, you mention them in profile


0

Cuttlefish is a tool that helps automate settings changes based on events such us as plugging and unplugging the power supply


0

Try changing the startup entry to this: x-terminal-emulator -e "bash -c '~/Desktop/Elaborati/script1.sh'" However, if you don't want the terminal to close once the script has finished executing, use this instead: x-terminal-emulator -e "bash -c '~/Desktop/Elaborati/script1.sh;echo Press any key to close this window...;read -sn1 null'" Why 'bash -c'? To ...


0

I think you meant to type, cd /home/Desktop/ or cd /Desktop/. Notice the capital letter D!!! ubuntu has tab completion to help you out for situations like this, basically you type the little you can remember and then press TAB for suggestions of what you want, eg cd followed by TAB


2

You could use sed for string manipulation: echo '$var = <string> 1.11 </string>' | sed -r 's/<string>(.*)<\/string>/\1/g' returns $var = 1.11 Explanation of the sed construct: sed -r # call sed with regex-option (-r) 's/ # begin of regex (s means "replace, / is the seperator) ...


0

I think init scripts need stuff like this at the begining : # Provides: chillispot et freeradius dans le chroot # Required-Start: $local_fs $network # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Wireless & LAN Access Point Controller # Description: ChilliSpot is an open ...


5

It does work ...even tested it, but the launcher icon is unresponsive for about 7 seconds after you clicked. If you click again after these 7 seconds, it will work again. This "break" is caused by the icon, waiting for a window to appear. This won' t be the case, since the appearing gnome-terminal -window is "claimed" by the gnome-terminal's launcher icon, ...


0

Go to a machine where you have set up a working configuration, and copy the file ~/.config/dconf/user to a USB stick or whatever. Now go to the client machine. Rename ~/.config/dconf/user to ~/.config/dconf/user-2016-06-16, and paste the config file from your computer that's set up the way you want it into the same place on the new machine. If it doesn'...


2

A bash script must start with a shebang, to let the launching process know it's a script that should be run in the bash shell. So the first line of your script should be #!/bin/bash. This is a good convention to get into, it is how bash scripts should be written. Your script currently works when you run bash /home/backupscript.sh because you're already ...


3

Make sure your script has set the execute flag when executing it directly or use bash as interpreter with the script as input. To use bash as interpreter change the line to 0 4 24-31 * 4 bash /home/backupscript.sh To set the execute flag for the script use: chmod +x /home/backupscript.sh


2

You can create new bash files simply with creating a new file and making it executable. e.g. touch simplebash.sh now add the shebang to the file so it knows in which shell you actually want to run the script. You can do this with this simple echo forward or just simple edit the file with an editor echo "#!/bin/bash" > simplebash.sh Change the ...


0

Look at this thread: How to uninstall NetBeans? If that doesn't work: Try looking for a readme or a help in the netbeans folder, and look for more information on uninstalling. You also can run the command gksudo nautilus, which opens your file manager which can delete all files, even those which normally are read only. Then go to other locations in that ...


1

set is often used to set the positional parameters ($1, $2, $3, etc., which are usually provided as arguments to the script). By using these parameters, we can get a simple way to count things via the $# variable, which stores the number of set positional parameters. ? is a wildcard matching any single character, so ??? matches any combination of three ...


1

Assuming bash, in a simple variable assignment, globbing is not performed: $ a=* $ echo "$a" * To get an array, you need to use parentheses: a=(*) For example, in /usr: $ a=(*) $ echo "$a" "${a[@]}" bin bin include lib lib32 lib64 local sbin share src So, your first line should actually read: files=(/satellite/MSGVIS6/*) To expand to all ...


0

can you try by placing below at top of script SAVEIFS=$IFS IFS=$(echo -en "\n\b") and IFS=$SAVEIFS in bottom of script


1

@markus-lindberg 's response is my favourite. If you add -o -4 to ip's flags then you get a much more easily parsable (and consistent) output: ip -o -4 a | awk '$2 == "eth0" { gsub(/\/.*/, "", $4); print $4 }' -o stands for --oneline, which is meant to help in exactly this kind of situations. The -4 is added to limit to the IPv4 address, which is what all ...


2

grep is a line matching tool , similar to findstr in Windows , except more powerful. What you see in your example is this structure: command | grep SOMEWORD >> file.txt The basic idea there is that we run command it's output will be given to grep for searching SOMEWORD and the resulting output will be only those line that contain the word FOUND. ...


2

"grep FOUND" will filter only lines that contain the word "FOUND" from the output of the "clamscan" command. It's not an option for grep, its the actual data that grep is looking for.


0

sudo clamscan -v -r /folder/to/scan/ will return results and those results are fed ("piped") to "grep". If in the results is the word "FOUND" it is added to the text file "/path/to/save/report/file.txt". The ">>" means to append to the file.


2

Usually, grep is used to display only strings containing a specified keyword, instead of displaying the entire output of a file or command in the terminal. From my understanding, sudo clamscan -v -r /folder/to/scan/ | grep FOUND >> /path/to/save/report/file.txt will read the scan file of ClamAV (it needs to specified), find any line in it that ...


4

The script bellow relies on all native tools of Ubuntu, pactl and qdbus to determine active app, automatically mute and unmute as the app gains and focus from user. The app name is set in APP_ICON_NAME variable. You can use pactl list sink-inputs | grep icon_name to determine the value you need it to be set. In my case, i tested it with chromium-browser . ...



Top 50 recent answers are included