Sponsored Content
Top Forums Shell Programming and Scripting Problem wth spec chars in script Post 303006271 by elxa1 on Monday 30th of October 2017 03:40:28 PM
Old 10-30-2017
Quote:
Originally Posted by jim mcnamara
Your answer is somewhat evasive.

Two ways:
1. use the printf method to embed punctuation and other odd characters. Unless you are using windows do not put \r in anything. expect gets a return from bash reading the script -- and it is a newline, \n

2. you can escape characters ( \ escape in front of each character, so \\ is read by the shell as a backslash, not escape). The shell takes them as literal characters, not some shell command -- example \*\# is an asterisk and an octothorpe (pound sign). Not a wild card and not a start of a comment.
Thank You Jim for your help - and sorry for my late reply. The problem is still actual for me.

So, I suppose, that only proper way for me will be the 1st method. Due to diversity of the passkeys it would be easier than putting backslashes in 2000-marks passkey's for example. The lenght of the keys can differ, and the special chars qty is also random.

About the method you mentioned:

1. I would like to use only in linux, and on linux I also can prepare passlist (unix-type line endings and non viible characters on passlist).

2. If that method (printf) could help - maybe 'expect' will not be essential?

I have tried using expect due to problems with using 7z x -p$klucz (or $passkey) archive.7z
The $ mark is only for calling a variable. That is possible, that on the begginning will be Dollar sign - $ .

Maybe your solution would allow me to use passkeys without bash-processing it in native 7z commands? So, if I can use it as a full text in script - 7z x -p$passkeyfromprintf

Unfortunately - I am starting with bash programming - and I really do not have idea how to use your snippet. Would you like to show me any example how to start using this ?


So, if I would use it my simpler script: (could you please help me with that one?)
"7z t" - 7z TEST, which wll exit when the passkey is bad.

Code:
2var=$(printf "%s%c" "\$klucz" 13)
while read $klucz 
do  7z t -p$2var archive.7z
echo $2var
done<passkeylist.txt

Is that should work?
regards
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies

2. UNIX for Advanced & Expert Users

Problem in FTP of file with chinese chars

Hi, I have a file in my PC with Chinese (PRC) characters. When I transfer that file into my AIX5.3 server through FTP, I get junk characters instead of Chinese chars. Last week I copied the content from my notepad and pasted in vi editor. The Chinese characters were correct, but when I try now,... (4 Replies)
Discussion started by: carthyc
4 Replies

3. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

4. Shell Programming and Scripting

wth...can't read my post

something is wrong, I can read every post except mine. Very weird, and extremely anoying I can see replies to my post but can't view them, instead it keeps trying to save the page and open it from downloads... but the downloaded page can't be viewed. Don't suppose someone can copy/paste the thread... (0 Replies)
Discussion started by: gcampton
0 Replies

5. Shell Programming and Scripting

Help wth Net::FTP in script sometimes fails but wsftp always works

Hi, I have a script that transfers files from a Solaris server to target unix servers. The script uses Net::FTP->put to write the files, which can be any number of files, not always the same. This script works flawlessly to many servers. For one particular instance of the script,... (3 Replies)
Discussion started by: csgonan
3 Replies

6. Shell Programming and Scripting

Calling script from a RPM spec file

Hi, I want to execute a script "myscript.sh" in the %post part of a rpm spec file. Suppose the script is placed in /opt/path. Then simply calling like sh /opt/path/myscript.sh from %post part (of that spec file) will suffice? Or there is any other way? (0 Replies)
Discussion started by: saurabhkoar
0 Replies

7. UNIX for Dummies Questions & Answers

Problem with replacing chars in file

my file is : hello1 hello2 hello3_B,dummy,N Need to change to : hello1 hello2 hello3_B,dummy_01,N Can anyone help? Thank you. Please use code tags next time for your code and data. (6 Replies)
Discussion started by: Alyssa
6 Replies

8. UNIX for Advanced & Expert Users

Script monitor website wth default tomcat script

Hi all, on our application server we have the following script that monitor the status of the website, my problem here is that i have edite the retries from 3 to 5, and the timewait to 120 second, so the script should check 5 times every 2 minutes, and if the fifth check fails it must restart... (0 Replies)
Discussion started by: charli1
0 Replies

9. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 09:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy