Tag Info

Hot answers tagged

3

I understand that your host, 192.168.2.7 is sending multicast packet to group 239.255.250.250 on port 9131 NOTE: I assume however that servers are listening on port 9131. you didn't provide any info on this. From ifconfig output, I can see that MULTICAST is enabled and the tcpdump confirm this. First make sure that the host running the servers (the one ...


3

This was an interesting one. The poster was trying to fix a machine that was accessible remotely over ssh. This machine had been partially upgraded to unstable, including libc6. However, parts were still on stable, and apt was at the squeeze version. The poster wanted the machine completely on stable. I walked the poster through fixing his machine. The chat ...


3

I am not entirely clear on how you get the output you show. I am assuming it is produced by the script you mentioned and that you can simply pipe it through something else to parse it. If so, these solutions should work: your_script | tail -n 2 | awk '/RMS/{print $4}' tail -n 2 prints the last two lines and the awk will print the 4th field of any line ...


3

script | sed -n '${x;p};h' That should do it, I think. It will always print the second to last line. If you want only the number you: script | sed -n '${x;s/[^0-9]*\([^ ]*\).*/\1/p};h' So big H appends to sed's hold space the contents of the current pattern space, whereas little h overwrites it. So if you overwrite the hold space for every line, and on ...


3

Short answer: Use Python 3! Seriously, it's great! I wish all the distros made Python 3 the default. The question of whether you should use Python 2 or Python 3 is not easy to answer without knowing about the users of your programs and which libraries you use. The practice of making it work on both is great exercise. Use Python 2 if one of these cases ...


2

PEP 394 specifies how Python should be installed and what to use in shebang lines. Use #!/usr/bin/env python2 for Python 2 scripts, and #!/usr/bin/env python3 for Python 3 scripts (and #!/usr/bin/env python if your scripts are compatible with both). In practice, people have been using #!/usr/bin/env python in shebang lines for years, so if you find a script ...


2

you could use awk (revised based on comments): awk '{a2 = a1; a1 = $4;} END { print a2 }' then just pipe your outpot into awk and you'll get 7.457 According to PyMOL's website, it's highly configurable and scriptable. It would be better to post the script you are using to SO and get some Python feedback.


2

That's expected behavior. cpulimit suspends the process when it consumes too much CPU resource and resume the process after a certain amount of time. Also check if your script is waiting for input? If so, your script will enter a stopped state as well. Try redirect stdin and run cpulimit again, e.g python run.py < /dev/null &


2

You need to install the numpy module to make it work: File "/usr/share/makehuman/makehuman.py", line 347, in main import numpy ImportError: No module named numpy In Slackware just download the numpy package and install it: upgradepkg --install-new numpy-1.8.0-i486-1_rlw.txz


2

awk: awk ' /__DELETE_THIS_LINE_BEGIN__/ {keep=1; next} /__DELETE_THIS_LINE_END__/ {keep=0; move=4; next} keep {saved[++s]=$0; next} move-- == 0 {for (i=1; i<=s; i++) print saved[i]; delete saved; s=0} 1 END {for (i=1; i<=s; i++) print saved[i]} ' file 01 text text text 02 text text text 09 four 10 interesting 11 lines ...


1

You will have to cache the lines that are between the markers and insert the cache after processing the 4 lines after the end-marker. In Python (tested with 2.7): #! /usr/bin/env python buffer = [] in_block = False max_interesting_line_nr = 4 begin_marker = "__DELETE_THIS_LINE_BEGIN__" end_marker = "__DELETE_THIS_LINE_END__" interesting_line = 0 with ...


1

Yes blocks are better as they are physical disk usage but you need to obtain them in a different manner Use the os.stat field st_blocks * 512. https://docs.python.org/2/library/os.html#os.stat os.stat(path) Perform the equivalent of a stat() system call on the given path. (This function follows symlinks; to stat a symlink use lstat().) On ...


1

There are a couple of things that can be done here. First is simple command substitution: cmd.py $(files.py) One problem here is that if there are any spaces, tabs or newlines in filename then these filenames won't be passed as a single argument and instead split into different arguments where these characters occur. One alternative is, if cmd.py outputs ...


1

Yes it can be done: cmd.py `files.py` Then first files.py is executed and the output (Example: "file1.txt file2.txt") is the input for the cmd.py. Example: cat `ls` This "cats" all the files found by ls in the working directory.


1

You'd probably be better off with nice as the way cpulimit is a bit of a hack and may play poorly with shell job control and other mechanisms. Since nice is a capability of the operating system which alters the scheduling priorities, this is much smoother than what cpulimit does which is allow a process to run as fast as it wants until it has exceeded a ...


1

When someone use #!/usr/bin/env python in the first line, he/she means the interpreter to run script is the first one found in $PATH, they don't assume script is compatible with both versions. If you want to specify python version to use in script, you can do like this: #!/usr/bin/env python2.7 or #!/usr/bin/env python3.3


1

Modern init systems such as systemd and upstart run multiple threads of execution, and even with the original init, things may be forked during the boot process (you've already said yours does, for example). This means your process is running at the same time as other processes, and any output will be interleaved with their's: Process 1 says "I'm here" ...



Only top voted, non community-wiki answers of a minimum length are eligible