linux

Strange behavior when running a bash script from java program

I have a script (KSH script to be precise) that downloads 3 files from a FTP server, using the curl command. When I run manually my script, i.e. by executing the command ./ftp_download.sh XXX (XXX are the parameters for the script), the download finishes correctly. As I want to run the script from a Java program, I have made a short Ja...

Awk pattern matching

I want to print userId = 1234 userid = 12345 timestamp = 88888888 js = abc from my data messssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss <input name="userId" value="1234" type="hidden"> messsssssssssssssssssss <input name="userid" value="12345" type="hidden"> messssssssssssssssssss <input name="timestamp" valu...

Ignore lines with same next fields as previous

I have a file contents of which looks like this 123,1,ABC,DEF 123,1,ABC 345,4,TZY 456,3,XYZ 333,4,TTT,YYY 333,4,TTT I want to ignore lines with the previous and next contents the same i.e lines containing 123 and 333 Output needs to be 345,4,TZY 456,3,XYZ Any ideas on how to go about this ...

Generating a random binary file

Why did it take 5 minutes to generate a 1 KiB file on my (low-end laptop) system with little load? And how could I generate a random binary file faster? $ time dd if=/dev/random of=random-file bs=1 count=1024 1024+0 records in 1024+0 records out 1024 bytes (1.0 kB) copied, 303.266 s, 0.0 kB/s real 5m3.282s user 0m0.000s sys 0m0....

C# Get File Owner from Linux File

I have a problem that I am hoping someone can help with. I have a c# application that needs to get the File Owner information from a file that resides on a Linux server. The .Net System.IO GetFileInfo throws an exception and the WMI calls fail. I know there is the PInvoke method GetFileOwner however the example on pinvoke.net is not comp...

Read data from pipe and write to standard out with a delay in between. Must handle binary files too.

I have been trying for about an hour now to find an elegant solution to this problem. My goal is basically to write a bandwidth control pipe command which I could re-use in various situations (not just for network transfers, I know about scp -l 1234). What I would like to do is: Delay for X seconds. Read Y amount (or less than Y if the...

priorities upload priority to give high priority to slingbox using htb qdiscs

I am trying to set slingbox connection to class 1:20 using the following commands: iptables -t mangle -A to-cable -p tcp --dport 5001 -j CLASSIFY --set-class 1:20 iptables -t mangle -A to-cable -p tcp --sport 5001 -j CLASSIFY --set-class 1:20 i have other class related commands for ssh, http and news. i use the command 'tc -s class ...

iptables - how to set class by ip address instead of port ?

i want to set a specific class to any packets that come from a specific computer in my network using --set-class, how can i achieve that ? ...

How do I add RIFF header to MP3 files programatically?

More information about what I want to do here; http://www.studiodust.com/riffmp3.html I want a way so that my control panel (made with Perl and Webmin) can do this automatically. Right now I have to rely on system calls and have a binary for Linux. Is there a library that does it for Perl or some other language? What's the best way of ...

Global environment variables in a bash script

How to set a global environment variable in a bash script? If I do stuff like #!/bin/bash FOO=bar ...or #!/bin/bash export FOO=bar ...the vars seem to stay in the local context, whereas I'd like to keep using them after the script has finished executing. ...

[linux kernel] get _complete_ process name from pid

hi, I am in a kernel module and I want to have the whole process name from a given pid. exactly: I want the line which is hold in /proc/PID/cmdline. The problem is that task_struct->comm[] is only 15 bytes long and doesn't handle if a program changes his argv[] manually or via setproctitle(3)... any ideas? :) ...

Improve my password generation script

I have created a little password generation script. I'm curious to what improvements can be made for it except input error handling, usage information etc. It's the core functionality I'm interested in seeing improvements upon. This is what it does (and what I like it to do): Keep it easy to change which Lowercase characters (L), Uppe...

What is better for a message queue? mutex & cond or mutex&semaphore?

I am implementing a C++ message queue based on a std::queue. As I need popers to wait on an empty queue I was considering using mutex for mutual exclusion and cond for suspending threads on empty queue, as glib does with the gasyncqueue. However it looks to me that a mutex&semaphore would do the job, I think it contains an integer and ...

On what conditions will a C++ program continue if the main thread is done?

I am debugging an issue, where there is a thread which continues to run after the main thread has exited. It is stuck in a loop where it is waiting for another thread to change a variable. I am trying to understand in what situations a process will continue running after the main thread has exited. I am using 32 bit linux g++ pthreads...

Linux/UNIX install data files

I understand that when installing a C++ command line program on Linux/UNIX, it is customary instead of leaving it in its original directory, to move it to a directory that is already on the path, so I have a make install entry: mv ayane /usr/local/bin Looking a bit further ahead, I'm going to end up with a directory or two full of con...

Get the layout mode (landscape or portrait) of a pdf from php/linux

Given a PDF, how can one get the layout mode of a PDF (or relative width/height) using a PHP lib or linux command line tool? Using http://www.tecnick.com/public/code/cp%5Fdpage.php?aiocp%5Fdp=tcpdf which can set this variable on new PDFs, but for existing pdfs from adobe. Thought of converting pdfs to ps, or using gs in some other way ...

To which segment do static variables from a dll go inside a process?

The static variables in an exe go into data segment of the process and initized at the start up of the process. So, if my process dynamically load a library, which has static variables using dlopen or something, to which segment these static variables will be mapped to. Also when these static variables will be initialized? My underst...

Smart methods for an Embedded Linux device to detect Internet connectivity

Our team is developing a Internet Media device based on Linux 2.6. Currently we detect whether Internet connectivity is established (via a wired Ethernet i/f) by pinging www.google.com Some networks we have tested the device on do not support ICMP packet forwarding so our application code mistakenly reports the Internet as unavailable ...

Per thread CPU statistics in Linux

I want to report the amount of CPU time used per thread in a server process (written in C/C++ on Linux). I can't find the equivalent of GetThreadTimes() on Windows, but that's what I'm looking for. Can anyone point me in the right direction? ...

Copying the .svn directories from a checkout to a non-checkout to make it a checkout

I have a large application in a production environment that I'm trying to move under version control. So, I created a new repo and imported the app, minus various directories and files that shouldn't be under version control. Now, I need to make the installed copy a checkout (but still retain the extra files). At this point, in a recent ...