I have a bash script with a few lines similar to the following Then I call that from a PHP script return shell_exec(“/path/to/bash/script arguments”); Now, when I do that, the command is run successfully, and outputfile.txt contains “Ran Command”. However, the PHP script times out afte…
Tag: bash
awk combine sequence with substring key
I have two files for combining with tab delimited file. That two files key might be different only for “Reads” number. I want to compare that two files and combined based on substring key and match. Forexample, This case I want to combine that two column with File1 Key name. Please check below exa…
List all groups on machine via bash script
This code gives me an output of 1000 if I’m a regular user or 0 if I’m root, while executing the same command (cut -d: -f1 /etc/group) returns a list of all the available groups on the machine. I also tried with grep “” /etc/group but that produces the same results. What am I not getti…
Execute root command with no root user avoiding password prompt
I have a script.sh file executing the following command: If i try to execute with a non-root user (username = marco), the prompt password halts the script waiting for the input. I’m trying to configure the /etc/sudoers file adding the following lines, but with none of them works and I’m always pro…
Bash completion sometimes meshes up my terminal when the completion function reads a file
So I’ve been having a problem with some cli programs. Sometimes when I kill the running process with Ctrl+C, it leaves the terminal in a weird state (e.g. echo is turned off). Now that is to be expected for many cases, as killing a process does not give it a chance to restore the terminal’s state.…
Attach to a GNU screen and then execute commands
I have seen some similar questions asked but the solutions don’t seem to work in my case. I am trying to SSH into a specific screen instance on a Node machine and then execute some commands My current process is this: On the remote machine I create a screen instance: screen -dmS “my_screen” …
Prevent accidental history editing in bash
I recently switched from tcsh to bash, and one thing that keeps tripping me up is how bash handles history. I regularly bring up a previous history command and begin to edit it, but realize I need to run a different command first. In bash, this edits the original command, and I cannot see what I originally ty…
How to write a bash script which calls itself with python?
Can someone explain how this bash script works? The part I don’t understand is “””:”, what does this syntax mean in bash? test running result: Answer That’s clever! In Bash, the “””:” will be expanded into only :, which is the empty command (it doesn…
Run find command from a bash file
Hi people: I’m making a xfe script to take a given directory as source file, use zenity to get output dir and perform some operations, for example: When the script is invoked, oggenc is not executed…any ideas? Solution: Based on answers bellow, this works as expected: Answer To make the variable $…
Am I setting this script up correctly to run specific commands based on user input?
I have a small script that I am working on. This is only the second script that I have made using bash script. Basically what I am wanting this script to do is take the users input and fire a command based on that choice. As you can see the user first enters the host address of the instance they