Tag Info

New answers tagged

1

Short story: don't use setuid shell scripts (or any setuid/setgid script). Long story: Allow setuid on shell scripts Solution: invoke the command using sudo. sudo arp -s 198.51.100.1 00:53:00:12:34:56 To allow the user steven to run this command without entering a password, run visudo and add the following line: steven ALL = (root) NOPASSWD: arp -s ...


0

Linux What you've posted is a snippet of C code. (And not even a working one.) It isn't going to work at a shell prompt. There is no shell interface to ioctl, but you can use Perl. #!/usr/bin/perl require "sys/ioctl.ph"; if (@ARGV) { $ioctl = 0x4b32; # KDSETLED $ARGV[0] =~ /^[0-8]+$/ or die "$0: $ARGV[0]: invalid argument"; $arg = ...


2

That C code would not work anyway -- fdopen() requires more than one argument and returns a file stream, not a file descriptor. I can remember doing this a few years ago, I thought via Xlib, but I could not find my old code (occasionally the collection gets purged) but I figured someone must have a simple app for this on github or something. Low and ...


5

Your problem is that you try to enter C code into a shell prompt, this doesn't work for obvious reasons. You could either put it into a correct C file, compile it and get a valid binary you could execute: #include <linux/kd.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <err.h> #include ...


-1

It's ok. It started working. I changed nothing: * * * * * source ~/.bash_profile; rsyncUbu4RedisFolder 2>&1 >> /tmp/cron55.out And it start working. Don't know why it did not work.


0

If your data always have some number of missing fields (i.e. 2 or more hard returns between records), you could simply: $ awk -v RS="\\n{2,}" -F"\\n" -v OFS="," '{print $1, $3, $4, $5, $6, $7, $8}' file.txt 1500,18,02,09,47,17,45 1501,27,54,28,50,22,03


5

Using awk: awk ' BEGIN { fields[1] fields[3] fields[4] fields[5] fields[6] fields[7] last_field=8 } ( NR%21 in fields ) { printf($0",") } NR%21==last_field' in_file.txt Or better yet: awk ' NR%21 ~ /^(1|3|4|5|6|7)$/ { printf($0",") } NR%21==8' in_file.txt GNU sed has a nice extension to match the nth line after a ...


3

Here's one way: $ perl -000ne '@f=split(/\n/); print join(",",@f[0,2..7]) , "\n"' file.txt 1500,18,02,09,47,17,45 1501,27,54,28,50,22,03 Explanation: -000 : activates "paragraph mode", it sets perl's field delimiter to \n\n, consecutive newlines. This means that it will treat each of your records as a single line. @f=split(/\n/); : split the current ...


1

Use Vagrant, it is a layer on top of VirtualBox and provides pre-made images called boxes, amongst them Ubuntu images.


1

VirtualBox with an Ubuntu Vbox Image.


0

sideways answer, OS X-specific in this case. One option, and the one that I used in the end in this case, was as follows: Use something to launch screen locally, which will work, and then re-attach to the session. I wrote a python program that generates and runs an apple script program which opens a new Terminal.app window and runs the command you asked ...


0

I should have known better, but OS X does not come with an X server. You need to install your own. Once you install XQuartz, you can restart and the problem goes away.


0

I just added these two lines in my .bash_profile works like a charm ulimit -n 1024 ulimit -u 1024


1

Your real world example shows that you are missing the destination. If you want to copy to the current directory, use .: rsync -a root@mysite.net:~/testingrsync/test2.flv .


0

On OS X 10.8, this seems to be ls -lO now (with a capital O). The output from man ls: -O Include the file flags in a long (-l) output. -o List in long format, but omit the group id.


0

If you happen to have zsh shell available, then zmv does almost exactly what you want, with very similar syntax: zmv '*.download' '$1.html' Just to point out why your attempt was wrong and dangerous: the wildcards *? are expanded by your shell before the command is even called. So, mv actually receives the entire list of files instead of *.download, but ...


1

mv doesn't work this way. You need another tool like rename or mmv. Please mind that there are two versions of rename around. And, of course, the shell can do that (with mv): for file in *.download; do fbasename="${file%.download}" if [ -e "${fbasename}.html" ]; then echo "${fbasename}.html exists; skipping." echo "${fbasename}.html exists; ...


0

rename 's/download$/html/' *.download should work for you


4

You can only use mv to move multiple files to a single directory in on call. One option here is to use prename (rename is linked to this on most systems, but not all): prename -n 's/download$/html/' -- *.download Remove -n when you are sure this is doing what you want. Another way is simply to use a loop: for file in *.download; do mv -i -- "$file" ...


0

I discovered the issues here that seemed to lead to this not working. First and foremost I had a symlinked ~/.Xdefaults and ~/.Xmodmap that are just excess from using the same dotfiles on Linux distributions. While neither of these seem to mess with any clipboard settings directly, removing them seemed to matter. Setting the pasteboard syncing options in ...


0

I cannot replicate your problem. I am using Emacs 24.3.1 which you can get either from emacsformacosx.com or MacPorts. Running Emacs with emacs -nw in Terminal.app (TERM=xterm-256color). Using M-x customize-theme I can select themes with colored backgrounds -- see attached image. It may be that the OS X Emacs /usr/bin/emacs, which is version 22.1.1 in ...


0

Unfortunately, to my experience at least if you use emacs in terminal you can't really change color schemes, Emacs, contrary to vim, is meant to be used in its own window not in cli.


1

You can view all application dependancies for a file with otool in Mac OS X. Here is an excerpt from the otool man page: The otool command displays specified parts of object files or libraries. For your specific need the following should work: otool -L $(which ctags) For additional files see this answer to a related question on where to look for ...


3

In the OSX 1.9 pppd source code, I found this in Helpers/pppd/pppd.h: #ifdef __APPLE__ #define EXIT_TERMINAL_FAILED 20 #define EXIT_DEVICE_ERROR 21 #endif #ifdef MAXOCTETS #ifdef __APPLE__ #define EXIT_TRAFFIC_LIMIT 22 #else #define EXIT_TRAFFIC_LIMIT 20 #define EXIT_CNID_AUTH_FAILED 21 #endif #endif #ifdef __APPLE__ #define ...


0

Not quite the same problem, but since I found this answer when googling, I'm providing my solution here too. I'm trying to find the firefox executable to execute it from scripts like cucumber / selenium tests. Here's what I do: Find it with Spotlight firefox_paths = %x[mdfind "kMDItemFSName = Firefox.app"] firefox_path = ...


3

pcregrep -MnirIso '(?s).{0,20}pseudomonas.{0,20}' . | grep --color -e '^' -e pseudomonas Assumes matches and their context don't overlap and that filenames don't contain pseudomonas. Also note that the reported line numbers are those of the beginning of the context.


4

cat file.txt | grep -o -P '.{0,20}string.{0,20}' This should do it for you Update: If you don't want to cat, you can just use the grep with the file as a parameter: grep -o -P '.{0,20}pseudomonas.{0,20}' FileName.html Hope it helps Also, The -P uses Perl Regex, which the man pages says is experimental, if you want to avoid that flag, you could just ...



Top 50 recent answers are included