[BASH] Getting a semi-tailing backslash when passing (escaped) variables to script
Heyas
Figured me had a 'typo' in tui-conf-set, i went to fix it.
Now, i also figured, it might be nice to have tui-conf-set report (to console, not only exit code) wether it could save the variable to the file or not.
This said, I appended this code: (the tui-title and tui-echo lines are just for debuging)
Which looks like:
Which doesnt look 'that' bad, but if you place this output in a terminal window, its quite annoying, please see the attachment.
The script is working, as it actualy saves or changes the passed value of a variable into the file, regardless of plaintext, variables or escaped variables.
Just when i enable verbose mode, to display wether or not the file could be written, ti 'display' fails due to an additional char/symbol i have no idea from where it is comming.
My assumption was, since special chars are passed (\ and $), it also invokes the change from $ to \$ (marked that section bold), and for some reason it appens a \ to the EOL sign $, but since its the EOL-sign (within a variable), one only char seen is \.
This theory is destroyed, as that variable is at the end of the output string seen in above text example.
The code below is prior to the finalcheck code from above:
Please, any ideas what/why its causing that backslash?
Thank you in advance.
NOTE:
With 'regular' (non-escaped) variables it works (the output between the DEBUG-st*) just fine too.
Hi, I'm writing a long script for bash (on RHEL 5.0) to execute many commands. So, my idea is to create a function to deal with error checking and logging (see ceckoutput() below). This works with all commands except for sed. I think it may be a problems with escaped characters. So I did the... (4 Replies)
Hello, Im writing a script that works by recursively going into directories with find. But I have some directories that have spaces in them.. so I need to parse the variables to add a backslash before the spaces.
Im not exactly sure how how to do this in bash, and honestly I dont think I know... (3 Replies)
I have a following problem:
#!/bin/bash
NUM=`cat accounts | wc -l`;
for i in {1..$NUM}
do
account=`awk "NR==$i" accounts`;
echo -e "\nAccount: $account\n";
sudo ./backup_maildir $account;
done "accounts" is a file with regular e-mail addresses, one in each line.... (2 Replies)
Hi All,
I am trying to add a tag in the *.imp file.
This is a piece of code which I am giving in my template file and my script reads this template file attachment and passes to windows server(as they have provided the below file path).
... (3 Replies)
Hello everyone,
I've been looking how to pass variables between bash and php-cli in 1 file. So far i got this:
#!/bin/bash
echo "This is bash"
php << EOF
<?php
echo "This is php\n";
?>
EOF
I would now like to be able to pass a variable declared in the bash to the php. I already... (0 Replies)
Hi All.
I have a file that contains some special characters and I'm trying to use AWK to search for lines between <pattern1> and <pattern2>.
As an example:
I need the lines between the line containing ' select_id="x_0 ' and the line containing the next instance of ' from '. This is a file... (5 Replies)
Not sure if this is possible, but I'm trying to read in a variable that needs to have its escape backslashes intact. So the person who enters the actual value does not have to type any \ characters. Example:
read list
X1000\ filecab.txt
echo "$list"
In this case the \ needs to be... (3 Replies)
Hi,
this is the example i'm trying to do.
script1.sh
ABC="test.txt"
./script2.sh "$ABC"
script2.sh
INPUT="$HOMEDIR/$ABC"
echo $INPUT
when i run the 1st script it gives me
../home/
the test.txt is not passed into 2nd script. How can i resolve this. (2 Replies)
Bash version 4.4.20 / Ubuntu 16.0.4
Hello,
I tried to write a script that gathers some data and passes them to an executable.
The executed application answers with an error. The echo output in the script returns correct values.
If I copy/paste the last echo command, it get's executed... (2 Replies)