User space bridging - Linux vs. FreeBSD

Background: I'm working on porting a packet parsing/manipulation program from FreeBSD to Linux (specifically Debian - jessie). This program implements a bi-directional bridge between two physical interfaces while performing parsing/manipulation prio...
more »

2017-06-16 21:06 (0) Answers

How to replace string in a file

I am writing shell script which will list the drivers .ko files and adding entry in init file. File comes in initramfs. so below some thing i have did in script, I tried google but solutions not working so finally i had to post question. few issues...
more »

2017-06-16 14:06 (1) Answers

sudo renice in python

Generically, this is a well answered question. Linux doesn't allow non-privileged users to lower a PID's niceness, and running things as root is its own can of worms. That said, here are my specifics: I've got a user account that manages a few proce...
more »

2017-06-15 21:06 (1) Answers

What the best way to delete files by extension?

I am looking the best way to delete files from directory by extension. I am planning to do it by date. But now, i am testing how it works. This: dir=/tmp/backup/ mask="jpeg jpg png gif bmp pdf" for i in $mask; do find $dir -name "*.$i" -type f -de...
more »

2017-06-15 16:06 (1) Answers

how to do if statements with "and" in sh

I try to solve this problem with the sh and not the bash. All i want is a if statement that check some regex AND something else. Normally in bash this would be an easy job but with the sh i only find solutions online that wont work for me First thin...
more »

2017-06-15 15:06 (3) Answers

Iterating over command-line argument pairs

I have a more than 400 coordinates that I want to pass as an argument into a string, but i don't know how to pass the first argument as "lat" and second argument as "lng" and so on for the rest. Say I was passing in this ./test 1 2 3 4 I want my...
more »

2017-06-14 22:06 (3) Answers

Iterate over $PATH variable using shell script

If I type echo $PATH in the terminal I get the following result: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/fnorbert/.local/bin:/home/fnorbert/bin I want to iterate over these paths using a shell script, but I do not know how to do th...
more »

2017-06-13 16:06 (5) Answers

sed replace group of files string

I am trying to replace a string in multiple lines. It is late and I'm getting restless, maybe someone would prefer to give it a shot for some SO points. The string I'm replacing is 'STORED AS TEXTFILE' from the SQL below... PARTITIONED BY(load str...
more »

2017-06-13 08:06 (2) Answers

GIT : Setting application environmental variables

In my GIT based project, I need to set several environmental variables which is required by build scripts and many other ant targets. For now I have a shell script which will export variables but each time a user opens a new bash window, he will nee...
more »

2017-06-13 08:06 (1) Answers

How can i find files containing multiple patterns

I have many files within folders and subfolders. I have file called patterns.txt which contains patterns per line. Now i want o find files which match all those patterns. Patterns can be in any order. Example patterns.txt userdata "/" "{a: 1}" ...
more »

2017-06-13 05:06 (1) Answers

strptime handling space in fixed format string

Is there a way to get strptime() to handle fixed format time strings? I need to parse a time string that is always on the fixed width format: "yymmdd HHMMSS", but with the complication that leading zeros are sometimes present and sometimes not. Re...
more »

2017-06-12 16:06 (1) Answers

Open a shell from buffer overflow

I have to open a shell in a c program with a exploit python script. I am using a Ubuntu VM to do this. The c program: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char buf[256]; strcpy(buf, argv[1]);...
more »

2017-06-12 12:06 (0) Answers

Compare directory structures

Is it possible to compare directory structures of two different server? I need to compare the directory structure of a test with that of a production server and list the directories that exists on prod but no in test (the test server has lot less inf...
more »

2017-06-12 11:06 (0) Answers