"here documents" and /tmp


 
Thread Tools Search this Thread
Operating Systems Solaris "here documents" and /tmp
# 8  
Old 02-19-2005
I think I misunderstood the OP - I thought of output redirecting and NOT about the here-doc itself.
My apologies.
# 9  
Old 02-19-2005
Data

Yes, I have a here-doc, but I do not redirect nothing to /tmp, it is done by operating system (os) automatically. So, if the filename assigned already exist on /tmp the os aborts my shell script. Your script would be great if I controlled the redirection, but it is driven by os. See below an extract from my shell script with a here-doc calling to sqlplus.


while [ 0 ] ; do

#-- check if cyclic process must be stopped

if [ -f $gp05000o_stop ] ; then
Flog "STOP RUNNING - $gp05000o_stop"
Fdelete_temp_files
Fexit
fi

#-- get the request from the users from the database

sqlplus -S $GMEP_USU/$GMEP_PWD << \
_eof_sqlplus > /dev/null

set termout off
set serveroutput off
set heading off
set linesize 400
whenever sqlerror exit 1 rollback

spool $gp05000o_process_to_run

select 'gp05000o','@', command, '@', rowid, '@', process_number, '@'
from oproc_call
where process_id = '$process_id'
and proc_status = '$process_wait'
and rownum = 1;

spool off

exit

_eof_sqlplus

. . .

done

=====================
error message reached
=====================
/disk1/gmeasp/code/sh/gp05000o.ksh[202]: /tmp/sh23628.13: cannot create
# 10  
Old 02-19-2005
Smilie My god!! Before rewriting the code, I will try to convince my sysadmin one more time to develop a easy shell script to remove old sh* files from /tmp, I do not think that it takes more than one line.
Thanks to all for your valuable help
This is my first contact in this forum, and it has been excellent
jterra
# 11  
Old 02-19-2005
Quote:
Originally Posted by jterra
Smilie My god!! Before rewriting the code, I will try to convince my sysadmin one more time to develop a easy shell script to remove old sh* files from /tmp, I do not think that it takes more than one line.
Thanks to all for your valuable help
This is my first contact in this forum, and it has been excellent
jterra
....before you do this.....
Cannot you simply avoid using here-doc as previously suggested?
I see you're using ORACLE sqlplus. You can save your sql statements in a temp file [using your OWN derivation rules] and simply pass it sqlplaus on the command line. [and remove the temp file afterwards].

I don't Oracle at my hands now, but it should be pretty easy.
# 12  
Old 02-19-2005
Yes, I could do it, but as you can see there are variables. And using here-doc the substitution is done by os automatically. However using my own file, first the sentences would be an additional component out of script, the substitution should be done manually using sed for instance, and ... I have a lot of code using here-doc. Any way, thanks for your suggestion.
# 13  
Old 02-19-2005
something like this should get you started:
Code:
typeset -i u="${$}"

# keep incrementing "u" till you find a non-existant tmp file
while :
do
   tmpFile="/tmp/sh${u}"
   if [ ! -f "${tmpFile}" ] ; then break; fi
   ((u = u + 1 ))
done

cat "
set termout off
set serveroutput off
set heading off
set linesize 400
whenever sqlerror exit 1 rollback

spool $gp05000o_process_to_run

select 'gp05000o','@', command, '@', rowid, '@', process_number, '@'
from oproc_call
where process_id = '$process_id'
and proc_status = '$process_wait'
and rownum = 1;

spool off

exit
" > "${tmpFile}"

sqlplus -S $GMEP_USU/$GMEP_PWD < "${tmpFile}"
....
/bin/rm "${tmpFile}"

# 14  
Old 02-19-2005
Just do something like...
Code:
filename=/tmp/jhjHkkkGRrqxbmXppoujuuyttrjfeJgfgg$$
echo "this
that
the other
last line" > $filename
program < $filename
rm $filename

*dang* vgersh99 beat me to it... I gotta type faster... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

Issue with rsync: failed to set times on "/tmp/.": Not owner (1)

Hi, Here is my source host and folder details. $ hostname source-host $ id uid=600000208(src-user) gid=64688(src-user) groups=64688(src-user) $ ls -ltrd /web/Trn_File/data/ drwxrwxrwx 3 src-user src-user 4096 Feb 7 15:27 /web/Trn_File/data/ $ ls -ltrd /web/Trn_File/data/* drwxrwxrwx 8... (1 Reply)
Discussion started by: mohtashims
1 Replies

4. Solaris

Solaris 10 error "-sh: /tmp/outfile: cannot create"

Hello, Each time a user log on to host, they receive below error: -sh: /tmp/outfile: cannot create Example: $ ssh host user@host's password: Last login: Fri Dec 4 08:17:28 2015 from client.ref |-----------------------------------------------------------------| -sh:... (2 Replies)
Discussion started by: feroccimx
2 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Script for delete tmp files older than 15 days and owned by "xxx" id

Hi All , I want to delete files from /tmp directory created by "xxxx" id. because i got the list says more than 60 thousand files were created by "xxxx" id since 2002. The /tmp directory has lot of files created by different user ids like root,system etc.. But, i need a script to... (2 Replies)
Discussion started by: vparunkumar
2 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question