Skip to content

Tag: shell

JSON list (not object) to Bash array?

I’ve got a JSON list (the value of a key-value pair containing a list of items): [ “john”, “boris”, “joe”, “frank” ] How would I convert this to a bash array, so I can iterate over them? Answer Easy Case: Newline-Free Strings The simple approach is to use …

Linux shell script regex match

I have a text file. I want to get lines starting with specific format. I just want to get lines that have x/x/x format. x is a number. But this regex is not working. It is always giving no match : File is : Answer Don’t use bash if you can use a better tool: But if you have to

pipe command make standard input broken

I have two processes: t1.cpp and t2.cpp. t1.cpp and t2.cpp are simplified ,I want to describe the problem easily. After compiling t1.cpp and t2.cpp. I execute them in this way ./t1 | ./t2. Problems occur! cin >> x; in t2.cpp failed! I have no chance to type from the keyboard. It seems the pipe command i…

run shell script from php as a specified user

I am trying to run a shell script from a PHP script. PHP code : my shell script : After I run the PHP code in a web server (Xampp), I got this output : Although, I haven’t set any password for the daemon user. And after I checked the current user running the PHP code I found it is

Shellscript If statement returns error

I am trying to check if a file is older than 5 minutes and if that is the case I want to call another shell script which sends me a mail. check_file.sh: Error output: 3: ./check_file.sh: [1]: not found Answer Try something like:

SSH and exec channels with python shell

We have implemented a python shell for our hardware devices that solely consists of the python cmd module on embedded linux. Our (non-root) user’s shell is set to the path of this python shell in /etc/passwd and /etc/shadow. Code example below: Previously, one of our clients had used SSH.NET to issue co…