Shell Script: "bash: Bad Substitution - Script for remove "." "
I am writing a program (script) and certain snippet of code requires that you remove the "." Of the network mask, ips, dns and others present in the insertion of data by the user.
The problem is that on a certain operating system (slackware 14.2) it runs perfectly, but the same script when released in kali 2016 (debian base:)) of the error when executing the script. Code:
#!/bin/bash In Slackware 14.2 the result of running this script is:: Code:
bash-4.3# sh linuxquestions-my-question.sh Code:
root@srv-001:/logs# sh linuxquestions-my-script.sh Until I found another way to do this, but now that I saw that it may be a mistake I really wanted to keep this script ... hehehe Thank you. |
I think "ip" is a binary on some systems.
Code:
whereis ip |
Quote:
:( |
It depends on your default shell. What is the output of the command
ls -l /bin/sh What happens when your run it via bash instead of sh bash linuxquestions-my-script.sh FYI you do not need the echo... Code:
newmask=${mask//./} |
Quote:
the output command ls -l /bin/sh is : Code:
root@srv-001:/logs# ls -l /bin/sh Code:
root@srv-001:/logs# bash linuxquestions-my-script.sh There is a simpler way to remove the "." Of network masks? I am very grateful to the clarifications, very much. Vlw .... Ahhh , its OK ! :) |
Now i use if and compare 19216815 is gt 192168254254 ...
if 192.168.1.5 > 192.168.254.254 then ; [...error]else[...ok] |
In addition using the shebang (#!/bin/bash) in the first line of the script allows you to run it as an executable. Just change permissions.
chmod 755 linuxquestions-my-script.sh You can run it from the same directory as ./linuxquestions-my-script.sh or using the full path. Post the actual if-then code. |
Quote:
I'm sorry, I had to translate the outputs and others PT.BR for EN.US The variables used are the program variables. The questions are the real ones. I have declared values for variables that will be the limits of both ip's and netmask. After the user enters values of ip and mask I do the following tests: Code:
#!/bin/sh |
I prefer using [[ ]] for conditionals but is the following real code or a comment?
Code:
Test if ip > 192.168.254.254 |
Quote:
my error. i use [[ ]] but i find errors, my erros.. :) |
Are you able to post the new changes? The whole revised script is even better.
|
Quote:
But it still does not 'complete' the script completely. My intention is that over the course of my days, when I have little work, extra time and / or tired of studying Python, I can improve it and, along with people like you, provide gateway configuration scripts, firewall, samba, An easy and simple way, without websites, without blogs. Something like this -> http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html#toc1 Without advertisements, without much mess, something clean .. What do you think of the idea? I know there is a lot of stuff, but it's never too much to have another exit, or have a second option and even study shell script. As for the proposal, I clearly agree, it would never go against a friend of free software. The first script is deb1.txt in http://gatewaylinux.info/gatewaylinux.info/deb1.txt :) |
Now I'm lost.... :)
|
Quote:
Owww. My englis is .... hehehe kkk I'm changing that, I understood that you had overhauled this part of the script. |
My problem is solved using this post.
http://www.linuxquestions.org/questi...9/#post5639270 Thank you brothers. :) |
All times are GMT -5. The time now is 06:43 PM. |