I’m trying to write a shell script, and in it I have to look for the presence of -32 in a string. Unfortunately I have to do it without using any bashisms as it has to run on computers running Dash. I tried case ${1+”$@”} in *-32*);; but that will pick up something like -321. Is there a way …
Tag: shell
Bash No such file or directory error
When I do It works fine. But when I do the same thing with I get ~/Desktop/out.txt: No such file or directory. Why? Answer Take the tilde out of the quotes so it can be properly expanded: You can also use ${HOME} if any subsequent part of your path contains spaces and you want to quote the whole path:
Bash script to install AWS CLI tools
I am writing a bash script that will automatically install and configure AWS CLI tools. I am able to install AWS CLI tools but unable to configure it. My script is something like this: I wish to do the configuration using this script too. I wish that I can provide these credentials via script so that it preve…
Use Bash variable within SLURM sbatch script
I’m trying to obtain a value from another file and use this within a SLURM submission script. However, I get an error that the value is non-numerical, in other words, it is not being dereferenced. Here is the script: When I run this as a normal Bash shell script, it prints out the number of procs correc…
Calling shell script from C++
A shell script test.sh is called from C++ code by the command execl(“/system/bin/sh”,”sh”,”test.sh”) After the execution of shell script i need to get back the control to C++, but the shell script is just exiting not executing the next instructions in C++ code Answer You wa…
Automate mysql_secure_installation with echo command via a shell script
I am trying to automate mysql_secure_installation script with automated response. My code is as follows : The actual questions which i am automating are as follows: But it gives me an error “Sorry you cannot use an empty password here” but in the screen i used to press the return key for the first…
how to transfer data between local and remote server connected via intermediate server?
I can login by ssh -X servA from local, then ssh -X servB from servA To copy data from local to servB, I scp files from local to servA, then from servA to servB. Is it feasible to copy files from local to servB directly and vice versa? Answer You can use nc (net cat) as a proxy for ssh.
How to move or resize X11 windows (even if they are maximized)?
I want to change position of a window. My problem is that the window can be maximized, this does not allow to change its size and location (window can belong to any application). I use KDE4. I tried to use ewmh Python module. In my case when the window is maximized I just want to move it from one monitor
Get MAC address using shell script
Currently all the solution mentioned for getting the MAC address always use eth0. But what if instead of eth0 my interfaces start with eth1. Also on OS X the interface names are different. Also the interface eth0 may be present but is unused. i.e. not active, it doesn’t have an IP. So is there a way I c…
How to remove commas in the middle of a specific line in a file in linux/unix
Someone was trying to be helpful in their test description. However, they added commas to the description so that when the test description is outputted to the log file, the results have extra commas. This makes it difficult to parse the results since the number of commas vary in the results file. I want to u…