ambiguous redirect error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ambiguous redirect error
# 1  
Old 04-20-2011
ambiguous redirect error

This script has ambiguous redirect error.

PHP Code:
...
cd $HOME
cd folder
/work
# search all subfolders in work directory
find -mindepth 1 -maxdepth 1 -type d | while read directory
do 
 
CUR_FOLDER="${directory#"./"}"
 
cd $CUR_FOLDER
 chmod 644 
*   
 
 for 
ff in *; do
  if [ ! 
"$ff"body.txt" ]; then 
   
   FILE_NAME
=`echo $ff | awk 'BEGIN{FS="."}{print $1}'`  #filename
   
FILE_EXT=`echo $ff | awk -F"." '{print $NF}'`     #file_ext
   
NEW_TXT_NAME=$FILE_NAME.txt
   NEW_XML_FILE
=$FILE_NAME.xml
   
   
echo $FILE_NAME $FILE_EXT $NEW_TXT_NAME $NEW_XML_FILE 
   
echo "111" >> $NEW_TXT_NAME
   
echo "222" >> $NEW_XML_NAME
  fi 
 done    
 cd $HOME
 cd folder
/work
done
... 




like it:

./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
AB023095 PDF AB023095.txt AB023095.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
0001 txt 0001.txt 0001.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
AB023069 PDF AB023069.txt AB023069.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
0001 txt 0001.txt 0001.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
AB023087 PDF AB023087.txt AB023087.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
0001 txt 0001.txt 0001.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Scan_201104201130 pdf Scan_201104201130.txt Scan_201104201130.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
0001 txt 0001.txt 0001.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
BAN 19-04-11 #2 pdf BAN 19-04-11 #2.txt BAN 19-04-11 #2.xml
./get_mails: line 36: $NEW_TXT_NAME: ambiguous redirect
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
0001 txt 0001.txt 0001.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
BAN 19-04-11 pdf BAN 19-04-11.txt BAN 19-04-11.xml
./get_mails: line 36: $NEW_TXT_NAME: ambiguous redirect
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect
Header Header Header.txt Header.xml
./get_mails: line 37: $NEW_XML_NAME: ambiguous redirect


please, tell me what wrong with this script?
# 2  
Old 04-20-2011
Can you change as below and try..?
Code:
NEW_TXT_NAME=${FILE_NAME}.txt 
NEW_XML_FILE=${FILE_NAME}.xml

# 3  
Old 04-20-2011
No, this didn't help Smilie\

It's strange that error appears with NEW_XML_NAME variable...
# 4  
Old 04-20-2011
Quote:
Originally Posted by candyme
No, this didn't help Smilie\

It's strange that error appears with NEW_XML_NAME variable...
The variable NEW_XML_NAME is not defined anywhere.
# 5  
Old 04-20-2011
Further to Franklin52 who has identified the main error, the latter part of your error messages did not come from the script posted.

I also suspect that shebang line (the very first line of your script) contains an error and that you may not be running the shell you think you are running.
Should be something like:
Code:
#!/usr/bin/sh

# 6  
Old 04-20-2011
Thank you, all

I solved this problem

I have to use

"$NEW_TXT_NAME "
echo "222" >> "$NEW_XML_FILE"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

$1”: ambiguous redirect

New to the site, please let me know I'm not meeting the post guidelines. I'm creating a bash script to generate a report with output from a grep command. The goal is to direct the output to a different log file by using a 'logger file'. But I get this error during the run: $1: ambiguous... (5 Replies)
Discussion started by: dallas88
5 Replies

2. Shell Programming and Scripting

Ambiguous output redirect in xterm

Hi all, I've been working on a bash script to help with backups that I have to do at work. One of the lines in the script is supposed to launch an xterm, log into a specific server node and launch a tar backup to tape. This part works ok, but I've been trying to get stdout and stderr to... (2 Replies)
Discussion started by: Exitalterego
2 Replies

3. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

4. Shell Programming and Scripting

Ambiguous error

Hello everybody, I just took over this job from someone else and in the past this script they built worked but i recently upgraded from openSuSe 11.4 to 12.1 Now when i run the script i get an ambiguous error at line 25 (the first line after add() ) I have edited out the webpath and any... (1 Reply)
Discussion started by: gumbicus
1 Replies

5. Shell Programming and Scripting

Receiving 'ambiguous redirect' when trying to run command against multiple files

I came across the command string on https://www.unix.com/shell-programming-scripting/141885-awk-removing-data-before-after-pattern.html which was what I was looking for to be able to remove data before a certain pattern. However, outputting the result to a file seems to work on an individual basis... (4 Replies)
Discussion started by: HLee1981
4 Replies

6. Shell Programming and Scripting

Ambiguous redirect

Hello there, I'm totally new in bash programming and ran into my first problem. My script should generate 3 textfiles where the content of the first and the third row are the same in each file. Only the second row is different. This is what I did in a very simplified explanation: ... (6 Replies)
Discussion started by: johndoe
6 Replies

7. UNIX for Dummies Questions & Answers

ambiguous redirect issue

I am trying to run the following script and I am getting an "ambiguous redirect" error. I have checked to make sure that the files are all where I have specified and are read/write as needed. Any ideas? Note: I have removed the actual path info for privacy sake. I have triple checked to make... (1 Reply)
Discussion started by: malantha
1 Replies

8. Shell Programming and Scripting

> to empty files, but ambiguous redirect

Hi Everyone, # ll total 0 -rw-r--r-- 1 root root 0 2010-05-13 11:29 a1.log -rw-r--r-- 1 root root 0 2010-05-13 11:29 a2.log -rw-r--r-- 1 root root 0 2010-05-13 11:29 a3.log # rm a.log above rm no problem, but when i use "> a.log", it says "-bash: a.log: ambiguous redirect". ... (3 Replies)
Discussion started by: jimmy_y
3 Replies

9. Shell Programming and Scripting

Ambiguous output redirect error

Hi everyone, While I was trying to do DATE=`date +"%Y%m%d_%H%M%S"` STARTLOG=$TUXSTDDIR/start_$DATE.log tmboot -y > $STARTLOG 2>&1 I got an error i.e. Ambiguous output redirect error. Here the first part is to boot the account so there is nothing wrong with that.... (6 Replies)
Discussion started by: pareshan
6 Replies

10. UNIX for Dummies Questions & Answers

ambiguous redirect

i have following statement in the script echo -e "$str_XML_col_name:$str_field_type;" >> $i_DC_Key_$i_Tgt_DC_key_Schema here $i_DC_Key is DC key and $i_Tgt_DC_key are the variables............... when i ran the script i am getting error rec_merge.sh: $i_DC_Key_$i_Tgt_DC_key_Schema:... (1 Reply)
Discussion started by: mahabunta
1 Replies
Login or Register to Ask a Question