I am writing a bash file. I need to start apachectl from my bash file. so i wrote: When I run it with root, an error occurred: I searched and I found that, I should be super user with su – not su Now, I want to know: why this error occurred? How could i run it with su? Answer
Tag: bash
cURL Simple File Upload – 417 Expectation Failed
I have a problem with a simple file upload post with cURL… I did it so many times but in this case I always get “417 Expectation Failed” from server. When I try to post with my browser it works 100% but with cURL not. That’s my configuration: My simple test form that works: here the image_upload.php: my cURL script
How to kill all processes with a given partial name? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question
Linux Shell: VLC programming
Is there a way to manipulate VLC with a Linux shell script without the script waiting for VLC to close. This code keeps running VLC until the file is completed, and then evidently it is to late to pause the file. Answer You need to use dbus interface of VLC. Now, you can use the mpris interface of VLC. It’s
How can I run a function from a script in command line?
I have a script that has some functions. Can I run one of the function directly from command line? Something like this? Answer If the script only defines the functions and does nothing else, you can first execute the script within the context of the current shell using the source or . command and then simply call the function. See
bash scripting: how to get item name on a radiolist using dialog
I need to make a radiolist in bash script using dialog interface, for example if I have the following list: I need when the user chooses an option and presses “ok”, my script could read the item’s name and not the item’s number. It is possible? Thanks! Answer You can put your expected results in an array:
Bash: add string to the end of the file without line break
How can I add string to the end of the file without line break? for example if i’m using >> it will add to the end of the file with line break: I would like to add yourText2 right after yourText1 Answer If your sed implementation supports the -i option, you could use: With the second solution you’ll have a
Open All files named generator.yml in all subdirectories of current directory in gedit
I’m no expert at shell scripting so I just want a quick answer. I tried something like but It just doesn’t work because it’s just a stupid guess. So what’s the correct way? UPDATE: answers by Jaypal Singh , kev and Sorin were very helpful but kev’s answer covers more cases so I’m marking that correct. Answer Or
split for words separated with semicolon
I have some string like 1;2;3;4;5 I want to be able to iterate over this string taking each word one by one. For the first iteration to take 1 the next to take 2 and the last 5. I want to have something like this but I do not know how to fill the myvar Answer
wget: downloaded file name
I’m writing a script for Bash and I need to get the name of the downloaded file using wget and put the name into $string. For example, if I downloading this file below, I want to put its name, mxKL17DdgUhcr.jpg, to $string. Answer Use the basename command to extract the filename from the URL. For example: