Help for resolving Unexpected EOF while assigning value to variable


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Help for resolving Unexpected EOF while assigning value to variable
# 8  
Old 11-15-2017
It really would help if I read your code more closely!
Not:
Code:
$ echo report_name
$ echo report_path

But:
Code:
echo $report_name
echo $report_path

It would also help if you read mine! Looking at this line:
Code:
SP2-0734: unknown command beginning "no='sqlplu..." - rest of line ignored.

There's clearly still no command substitution there, just a single quote.

Please post the script now, after these changes, so we can start afresh. This is already dragging on more than I'd like Smilie

And I really would appreciate if you'd use code tags this time! You have TWO private messages showing you how to do that. It's not complicated.
This User Gave Thanks to Scott For This Post:
# 9  
Old 11-16-2017
Code:
#!/bin/sh
. /opt/ora/oracle/db/tech_st/11.2.3/PROD_darwin.env
#sqlplus -s "apps/apps" << EOF
no=$(sqlplus -s apps/apps<<EOF
set heading off
set feedback off
Select 
pt.user_concurrent_program_name report_name , OUTFILE_NAME report_path 
FROm 
apps.fnd_concurrent_programs_tl pt, 
apps.fnd_concurrent_requests f 
where 
pt.concurrent_program_id = f.concurrent_program_id 
and pt.application_id = f.program_application_id 
and f.RESPONSIBILITY_ID = 52431 
and trunc(f.request_date) = trunc(sysdate);
exit
EOF
)
report_name=`echo $no | awk '{print $report_name}'`
report_path=`echo $no | awk '{print $report_path}'`
echo $report_path
echo $report_name
scp  $report_path /opt/report

now variables are showing the assigned values of Report_name and report_path
i am copying the report output file to opt/report
but its showing error. below is the output of the above script

Code:
[oracle@darwin ~]$ . /home/oracle/scripts/u1.sh
Daily Yarn Clearance Summary Report (NCML / ESML) -Customized /opt/ora/oracle/inst/apps/PROD_darwin/logs/appl/conc/out/o16737993.out Lab Test - Customized /opt/ora/oracle/inst/apps/PROD_darwin/logs/appl/conc/out/o16737995.out
Daily Yarn Clearance Summary Report (NCML / ESML) -Customized /opt/ora/oracle/inst/apps/PROD_darwin/logs/appl/conc/out/o16737993.out Lab Test - Customized /opt/ora/oracle/inst/apps/PROD_darwin/logs/appl/conc/out/o16737995.out
cp: cannot stat `Daily': No such file or directory
cp: cannot stat `Yarn': No such file or directory
cp: cannot stat `Clearance': No such file or directory
cp: cannot stat `Summary': No such file or directory
cp: cannot stat `Report': No such file or directory
cp: cannot stat `(NCML': No such file or directory
cp: omitting directory `/'
cp: cannot stat `ESML)': No such file or directory
cp: invalid option -- C
Try `cp --help' for more information.
cp: cannot stat `Lab': No such file or directory
cp: cannot stat `Test': No such file or directory
cp: cannot stat `-': No such file or directory
cp: cannot stat `Customized': No such file or directory



Moderator's Comments:
Mod Comment Seriously (after two infractions): Please use CODE tags for code and data as required by forum rules!

Last edited by RudiC; 11-16-2017 at 05:06 AM.. Reason: Added CODE tags.
# 10  
Old 11-16-2017
First: It usually helps if people read the entire responses / comments, so you might want to reconsider

Quote:
Originally Posted by Scott
. . .

Using $report_name and $report_path inside your awk won't work, as they're shell variables, and not awk variables (and in awk, using $ before them would make them equate to the position of a variable, not the variable itself). You might find what you're looking for in positional variables ($1, $2, etc.) inside the awk, or you might not need awk at all, depending on, actually, what output you are looking for.

. . .
As used, in awk the variables report_name and report_path are undefined, and thus in both cases the entire line ($0) is referenced and printed, and assigned. This might not be the desired result.

From the (unstructured) output you present it can be inferred that
- the resulting columns have spaces in them and are separated by spaces; might be difficult to distinguish - that's why the cp fails...
- there's more than one result line, so you may need to individualise single items in a loop.

Plus, as both source and target seem to be local files, why do you run scp (sort of network copy)?
This User Gave Thanks to RudiC For This Post:
# 11  
Old 11-16-2017
Actually report_path is the location where pdf report is saved on server. i have to copy it to /opt/report folder. As report name is with id so i will rename with report_name.
through SQL, path and required name for update has been achieved, Now it has to copied and rename.I think using cp command and passing variable with assign values can solve this. I will be thankful if you suggest any alternate or easy way for this
# 12  
Old 11-16-2017
Show exact details, your description is too vague. And, consider to rephrase the SQL query; you might be able to immediately output the correct command(s) to be fed into a subshell. Again: spaces in the result may spoil the behaviour of the downstream commands.
# 13  
Old 11-17-2017
Ok, let me describe the requirement again and that is copy the files from one location to another and rename the copied files.
Source location and names to rename the files comes from SQL query. Query results two columns. One is the report name and other is path where file is currently placed.
Shell script will read the report name and path from the first row of the query.
Copy the file then rename it and moves towards next record and so on till end of query records.

---------- Post updated 11-17-17 at 02:06 AM ---------- Previous update was 11-16-17 at 05:34 AM ----------

I would like to thanks for the support and advise. Lean something new from experts.
Problem has been solved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unexpected EOF while loooking for matching '"

Hi everyone, I'm really new in shell scripting and having trouble resolving this error. Can someone please tell me why I'm getting these errors? Error Message: ./test.sh: line 50: unexpected EOF while looking for matching `'' ./test.sh: line 53: syntax error: unexpected end of file ... (4 Replies)
Discussion started by: simonirang
4 Replies

2. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

I have a piece of Linux script. It tells me some syntax error. I couldn't find it. Please help me to identify them. Thanks. The code looks like this: export ORACLE_SID=MYDB export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID` export check_arch=`sqlplus -s << EOF / as sysdba... (7 Replies)
Discussion started by: duke0001
7 Replies

3. Shell Programming and Scripting

eof unexpected while looking[...]

Hello I use opensuse build service to build packages (oh surprise !) I have integrate a command in a spec whose worked and now this exit with: unexpected EOF while looking for matching `"' Command: if \.").mk ]; then ln -s $(pwd)/mozilla/security/coreconf/Linux2.6.mk \ ... (5 Replies)
Discussion started by: posophe
5 Replies

4. UNIX for Dummies Questions & Answers

Unexpected EOF in .profile

When opening a new window under Terminal, got that message: Last login: Sun Oct 30 10:35:12 on ttys000 -bash: /Users/MyName/.profile: line 47: syntax error: unexpected end of file I tried several clues like using BBedit or emacs to get rid of it, nothing does. Maybe shell commands cut or... (1 Reply)
Discussion started by: shub22
1 Replies

5. Shell Programming and Scripting

unexpected EOF : BASH

i'm writing a bash script that uploads a file to my server but it keeps saying unexpected EOF... i cannot see the problem with it, and it worked before i edited the script to work on my ipod touch as well. Here is the troublsome code... if ; then tar -czf "file(Mac).tar.gz" "/folder" >... (11 Replies)
Discussion started by: DuskFall
11 Replies

6. Shell Programming and Scripting

Stuck with Unexpected EOF

Hi, i have a script as below. i'm using sun solaris 10. Script : #! /bin/sh load() { find /stage_area/loadfiles/telsims/test/ -type f -name "*$1" -print > /tmp/testfile.txt fc=`cat /tmp/testfile.txt | wc -l | sed 's/ //g'` if ; then echo " Files Not Avaliable" exit else... (12 Replies)
Discussion started by: apple2685
12 Replies

7. UNIX for Dummies Questions & Answers

unexpected EOF

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please enter if its sinle player game... (1 Reply)
Discussion started by: Freakhan
1 Replies

8. Shell Programming and Scripting

Unexpected EOF while looking for matching `"'

Hi everyone, I am trying to search for a string in a file that is partly made up of a variable. Here's the code: echo "parentCategory = $parentCategory" echo "parentCategoryFormatted = $parentCategoryFormatted" numUrlsFoundInParentCategory=`grep -c "<Topic r:id=\"Top\/World\/Français\/"... (2 Replies)
Discussion started by: BlueberryPickle
2 Replies

9. UNIX for Advanced & Expert Users

unexpected EOF

I ran the following scripts and everytime i get the errot as follows Line 54: unexpected EOF while looking for matching ',' line 57 syntex error unexpected end of file#!/bin/ksh set -x BKUP_DIR=/u03/backups/abu/nightly_backup LOG_FILE=/u03/backups/abu/backup.log ORACLE_HOME=... (9 Replies)
Discussion started by: manna
9 Replies

10. Shell Programming and Scripting

Unexpected eof error

Hi, I am newbie and am just trying to connect to oracle from shell script ,,,but I am getting the following error ./prog.sh: line 20: syntax error: unexpected end of file The scripts is : #!/bin/bash O=$IFS; IFS=","; while read a b c d do echo $c ... (6 Replies)
Discussion started by: thana
6 Replies
Login or Register to Ask a Question