Tag Info

New answers tagged

0

I'm using Fedora 19, i did little test, sudo uses Defaults env_reset and Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin in few worods, with this two directive, sudo uses his own env variables commenting this two options in /etc/sudoers and adding my current working directory to my PATH it's work sudo sudotest.sh + ./ruby.rb hello ...


1

Me too was having this problem. I am now able to run my mono c# app on start up with the help of: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html In the "start" section of file (as specified in the above link), do the following: 1. change directory to the folder of your c# app: cd /home/pi/myApp 2. in the next line, add ...


3

You have a recursive error. You define a function called 'ssh' then call the same function in your function. This results in a recursive loop. Specify the absolute path to the ssh binary and that should fix it.


3

Adding to what's been said by @nonsenz, If you use puphpet.com's provisioning scripts then you can add a bash file to the /puphpet/files/startup-always folder and place all your commands in there. Anytime vagrant starts or reloads it will call the script: mysql.sh #!/bin/bash echo "Updating mysql configs in /etc/mysql/my.cnf." if [ sudo sed -i ...


1

You can read the text currently displayed on the screen from /dev/vcs. If your terminal window has the same number of columns as the actual screen output on the server, then you can simply type cat /dev/vcs and get a recognizable output. You can append a number to access a specific console rather than always the active console. And you can use vcsa, if you ...


3

If it's an actual server, it will have out of band management (IPMI) features which will allow you to access the system console. For instance Dell servers call it iDRAC, HP servers have iLO, etc. If your server has no such functionality then you can connect an IP KVM device to it.


0

an alternative - assuming you need to keep the lines separated by 'newline' - would be to write first to a temp file, and then user logger -t <title> -f <temp-file>


3

Logger doesn't contain this functionality it is basically line orientated - every line is a new message. Multi-line log messages are also a real pain to deal with using standard utilities like grep etc. Depending on their arrival time the messages could also get split making it harder to track down relevant information. A better solution is to log your ...


2

Sure, just replace \n by space as this : echo -e "foo\nbar" | tr '\n' ' ' | logger


0

Try so: out=`command args...` || echo $out


2

I'd setup a bash function like this: function surpress { /bin/rm --force /tmp/surpress.out 2> /dev/null; $* 2>&1 > /tmp/surpress.out || cat /tmp/surpress.out; /bin/rm /tmp/surpress.out; } Then, you could just run the command: surpress foo -a bar Hope this helps!


1

going short with something like tehcommand &>/tmp/$$ || cat /tmp/$$ depends how much usability/typing you want/need. (e.g. using it as a pipe or passing the command by argument) @zoredache short script is basically a proto-wrapper for this, which would give more robustness, handle concurrency, etc


4

It should be easy enough to write a script for this purpose. Something like this completely untested script. OUTPUT=`tempfile` program_we_want_to_capture &2>1 > $OUTPUT [ $? -ne 0 ]; then cat $OUTPUT exit 1 fi rm $OUTPUT On the other hand for commands I run as part of a script I usually want something better than simply print all the ...


5

I don't think there is a clean way of doing this, the only thing I can think of is Capture the output of the command. Check the return value of the command and if it failed display the captured output. Implementing this might though be a interesting project but perhaps beyond Q&A.


0

It's actually ssh that's slurping up stdin. Just add the -n option: c=$( ssh -n $b normal-script ) If you don't want to do that, you can have your shell while loop read from a different file descriptor, leaving stdin untouched: while read -u3 a b c d do s=$( expect-script server1 $b ) c=$( ssh $b normal-script ) echo $s $c done 3< ...


1

cat /tmp/file | while read a b c d do { s=`expect-script server1 $b` c=`ssh $b normal-script` echo $s $c } < /dev/null done The { command... } syntax allows you to apply redirection or piping to a sequence of commands. I'll also note that you don't need cat in your example. You could do this: while read a b c d do ...


0

Clean /usr/lib/locale/ (delete everything, do a backup if you are afraid). Delete unneeded locale from /etc/default/locale file (do not delete this file, edit and delete the locales) Delete unneeded locale from /var/lib/locales/supported.d/* files (do not delete this files, edit them and delete the locales) Regenerate locales (locale-gen --purge). Also ...


0

Sure? you have run it as root or using sudo: sudo locale-gen --purge en_US Because it doesn't raise any error if you run it as regular user


1

sudo edit /etc/default/locale Edit the LANGUAGE variable to remove whatever language that needs removed. Then reboot. sudo apt-get install localepurge After that you can run localepurge to remove old locale files.


0

It's possible using virtual terminals for KVM VM. You need (keep in mind all my examples for Debian 6/7): Run Linux kernel inside KVM VM with kernel param: console=tty0. it can be done editing /etc/default/grub : GRUB_CMDLINE_LINUX_DEFAULT="quiet console=tty0" Add to KVM VM file /etc/inittab this line:T0:23:respawn:/sbin/getty -l /usr/local/bin/autologin ...


1

This command works regardless of the directories' names. To remove the third oldest directory: ls --sort t -l | grep -v total | awk '{print $9}' | head -n -2 | tail -1 | xargs rm -rf


1

Try this: ls -1tr | grep 2014\- | head -1 | xargs rm -rf


3

Yes, you're probably quite fine. Assuming en_US.utf8 contains a UTF-8 American/English locale, it should work just fine. That's what I use myself: % echo $LANG en_US.UTF-8 If you run locale -v -a, it'll be a bit more descriptive: % locale -v -a locale: en_US archive: /usr/lib64/locale/locale-archive ...


-3

en_US.utf8 contains everything ASCII does but I don't think it covers any more than that. Your system won't be able to print/view characters other than those and will display a box (or a box with a question mark in it) when it encounters one of these unknown characters.


0

Heres a find one-liner. find ./ -type d ! -regex '.*.ENDING$' -printf "%h\n" | sort -u Edit: Oops, wont work either.


1

Inspired by Dennis Nolte's and MikeyB's answers, I came up with this solution: find . -type d \ \! -exec bash -c 'shopt -s failglob; echo "{}"/*.ENDING >/dev/null' \; \ -print 2>/dev/null It works based on the fact that if the failglob shell option is set, and no matches are found, an ...


1

I'd do it in perl personally #!/usr/bin/perl use strict; use warnings; use File::Find; #this sub is called by 'find' on each file it traverses. sub checkdir { #skip non directories. return unless ( -d $File::Find::name ); #glob will return an empty array if no files math - which evaluates as 'false' if ( not glob ( ...


3

Here we go! #!/usr/bin/env python3 import os for curdir,dirnames,filenames in os.walk('.'): if len(tuple(filter(lambda x: x.endswith('.ENDING'), filenames))) == 0: print(curdir) Or alternately (and more pythonic): #!/usr/bin/env python3 import os for curdir,dirnames,filenames in os.walk('.'): # Props to Cristian Cliupitu for the better python ...


7

Here's a solution in three steps: temeraire:tmp jenny$ find . -type f -name \*ENDING -exec dirname {} \; |sort -u > /tmp/ending.lst temeraire:tmp jenny$ find . -type d |sort -u > /tmp/dirs.lst temeraire:tmp jenny$ comm -3 /tmp/dirs.lst /tmp/ending.lst


2

The shell expands the *, but in your case there's no shell involved, just the test command executed by find. Hence the file whose existence is tested, is literally named *.ENDING. Instead you should use something like this: find . -type d \! -execdir sh -c 'test -e {}/*.ENDING' \; -print This would result in sh expanding *.ENDING when test is executed. ...


1

Sysdig - this is what you want ;) example: sysdig -i spy_users Category: Security spy_users Display interactive user activity lists every command that users launch interactively (e.g. fr om bash) and every directory users visit Args: (None) sysdig is powerful tool of system-level exploration. See more: http://www.sysdig.org/


0

You can also distribute the file stream with tee and then split in parallel: <file tee >(grep '^foo' > foo.txt) >(grep '^bar' > bar.txt) > /dev/null Result: $ tail -n+1 foo.txt bar.txt ==> foo.txt <== foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz ==> bar.txt <== bar xxx yyy zzz bar xxx yyy ...


1

awk '{ f = $1 ".txt"; print > f }' file


1

grep ^foo input.txt > foo.txt grep ^bar input.txt > bar.txt ^ will make sure you only match the beginning of the line, so it will work even if the rest of the line looks like: foo xxx yyy zzz bar


1

Try this code, and make any chages if need since i have not tried to run it. awk ' BEGIN { foo="foo.txt"; bar="bar.txt" } {if ($1 == "foo") $0 >> foo; else $0 >> bar; }' sourcefilename


4

grep -E '^foo' input.txt > foo.txt grep -E '^bar' input.txt > bar.txt mbp-000234:~ dmourati$ cat foo.txt foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz mbp-000234:~ dmourati$ cat bar.txt bar xxx yyy zzz bar xxx yyy zzz



Top 50 recent answers are included