ignoring backslash while executing command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ignoring backslash while executing command
# 1  
Old 11-14-2005
ignoring backslash while executing command

Hi, I'm running into following issue, my_file is a collection of windows directories (i.e \\path\directory\file) . I need to be able to execute "my command" as
my command \\path\directory\file
I know that while read -r / print -r ignores backslashes.
My code:

cat $my_file | while read -r line
do
my_array[$i]=$line
(( i = i + 1 ))
myarray[i]=$line
done
(( h = 0 ))
while (( h < `cat $my_file | wc -l ))
do
my command ${my_array[h]}

this executes incorrect values

print -r "my command ${my_array[h]}"

this sends correct output to the screen

(( h = h + 1 ))
done

Appreciate any help.
# 2  
Old 11-14-2005
Maybe this will do it:
eval my command \'${my_array[h]}\'
# 3  
Old 11-14-2005
Question

Is there a limit to how many characters can be passed to command line? My command is getting truncated and therefore cannot be validated. Smilie
# 4  
Old 11-14-2005
2048 is a common limit but it varies from os to os.
# 5  
Old 11-16-2005
Quote:
Originally Posted by Perderabo
2048 is a common limit but it varies from os to os.
Ok, but then how do using this approach
eval my command \'${my_array[h]}\'

execute this

eval my command \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\' \'${my_array[h]}\'

Smilie
Thanks.
# 6  
Old 11-16-2005
I do not understand your question. If the command I gave you resulted in 11 copies of the array element being passed, I cannot explain that. I would have expected only one copy. Smilie
# 7  
Old 11-16-2005
no, what I am saying is I have a number of arrays to pass to eval, my question is if I do
eval my command \'${my_array[h]}\' my array returns a long string and if I have say three arrays to pass can I do each one on new line and how will eval interpret it?

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies

3. Shell Programming and Scripting

sed command escaping backslash "/"

Hello friends/'unix experts', i have a file as below cat sample.txt satish /rakesh/ sandhya /sandeep/ i have to replace /rakesh/ with rakesh, how can i do it with sed, i tried below code but its throwing errors sed -e 's/'"\(/rakesh/)\"'/\1rakesh/g' sample.txt ... (1 Reply)
Discussion started by: only4satish
1 Replies

4. UNIX for Dummies Questions & Answers

Replace backslash at the end of the string using sed command

I have text file which is a tab delimited one. Sample data from the file is shown below: unix is\ great\ os linux\ is superb I want to replace that backslash with empty string preserving the tab delimiter. Output should be unix is great os linux is ... (3 Replies)
Discussion started by: p.akhilreddy4u
3 Replies

5. Shell Programming and Scripting

Error while executing sh command

Hi, I have 2 files temp1.sh and temp2.sh as follows: =========== temp1.sh =========== echo "session1" sh temp2.sh echo "exit session2 and enter session1" ================================= ============= temp2.sh ============= echo "session2" sh echo "exit session2"... (5 Replies)
Discussion started by: RP09
5 Replies

6. Shell Programming and Scripting

How to disable backslash in command line

Dear I have one problem in SCO Unix command line. I want to disable execution of commands with backslash. For example - if the user executes the following command \exec_script Here - i want the system should NOT execute this command. Can any one give me a suitable... (8 Replies)
Discussion started by: subbu62
8 Replies

7. UNIX for Dummies Questions & Answers

What prefix backslash does to command

In unix when I run rm command, it asks for file removal confirmation e.g. rm netmail_log.csv rm: remove netmail_log.csv (yes/no)? n But if i prefix backslash to rm it does not ask for confirmation. Does anyone know what backslash does to command or shell ? e.g. \rm netmail_log.csv (1 Reply)
Discussion started by: Devdatta
1 Replies

8. Shell Programming and Scripting

File Comparison command but ignoring while spaces

Hello All, I am writing a file comparison utility and using the cmp command to compare 2file. But I need command that will compare 2 files and if the files are identical expect for differences in white spaces, then it should ignore those spaces and consider the two files equal. Is there a way to... (7 Replies)
Discussion started by: Veenak15
7 Replies

9. Shell Programming and Scripting

"read" command ignoring leading spaces

I have to read a file line by line, change it and then update the file. Problem is, when i read the file, "read" command ignores leading spaces. The file is a script which is indented in many places for clarity. How to i make "read" command read leading spaces as well. (3 Replies)
Discussion started by: vickylife
3 Replies

10. UNIX for Dummies Questions & Answers

Backslash in find command

When I run my script in debug mode I see that \ is not getting executed as part of command. It is being treated as escape character. find ${DATABASE_PARAM_PATH} -mtime +${RETENTION_PERIOD} -exec rm -rf {} \; Command execution output in debug mode : find... (1 Reply)
Discussion started by: findprakash
1 Replies
Login or Register to Ask a Question