Embedding file output into a script


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers Embedding file output into a script
# 1  
Old 06-02-2009
Embedding file output into a script

Hello.

I found a Unix script on this site that calculates a date that is 2 months earlier from today. I'm using that script and writing the value to a file called 2monthsago.txt. I want to use that value in another script. Below is my attempt at doing that and the results.

My Script:

#!/usr/bin/ksh
# My attempt to run the Process Flow Maintenance scripts in lawson

chmod 777 /home/iclac/script_writing/2monthsago.txt;

udate=`/home/iclac/script_writing/2monthsago.txt`
rdate="`date "+%m/%d/%Y"`";
#chomp($rdate);

print "Run Date $rdate, Purge Thur $udate\n";
print "perl $GENDIR/bin/batch.pl MoveWorkunitToHistory move -outputFileName /apps/lawson/law/bpm/wflog/archive/pflows_move_hist.txt -processThurDate $udate\n";

Results:

ucasd80:iclac:/home/iclac/script_writing# ./ProcFlow_maint
/home/iclac/script_writing/2monthsago.txt: 04/30/2009: not found. **** It shows the value but I'm not sure why it reports ‘not found'
Run Date 06/01/2009, Purge Thur __________ **** It is supposed to be listing the ‘04/30/2009' date here.

perl /apps/lawson/gen/bin/batch.pl MoveWorkunitToHistory move -outputFileName /apps/lawson/law/bpm/wflog/archive/pflows_move_hist.txt -processThurDate


I've also tried the udate line with double quotes and then no quotes. When I do that it reports the sting as the value - see below.
Code: udate="/home/iclac/script_writing/2monthsago.txt"

Results: Run Date 06/02/2009, Purge Thur /home/iclac/script_writing/2monthsago.txt

Any thoughts on what I'm doing wrong.
Signed: Utterly confused aka Leslie



-----Post Update-----

With the help of a co-worker we got it working.

I needed to change my udate line from the above to what's listed below:

udate=`cat /home/iclac/script_writing/2monthsago.txt`;

It now works like a charm.
Thanks!
# 2  
Old 09-08-2009
Code:
udate="/home/iclac/script_writing/2monthsago.txt"

should read:
Code:
udate=`/home/iclac/script_writing/2monthsago.txt`

By the way scripts are normally saved with a ".sh" filename suffix so others know it is a script and not a text document.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

2. Shell Programming and Scripting

Embedding JPEG image to the body file

hi, I am trying to embed an image to the body of the email, but the image is not visible. echo "<html> <body> <style> body {background-color:blue} </style> <h1>hello</h1> <center> <img... (1 Reply)
Discussion started by: ATWC
1 Replies

3. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

4. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

5. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

6. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

7. Shell Programming and Scripting

Need help embedding Unix commands in a shell script

Hi Folks, I have a text file which may or may not have any data. I would like to email the file, via a Korn shell script, if the file is not empty. I am fiddling around with the wc -l command, but no luck so far. The pseudo code is as follows count=`wc -l test.txt` if cat test.txt... (4 Replies)
Discussion started by: rogers42
4 Replies

8. Shell Programming and Scripting

Embedding HTML in Perl script

My webpage is hosted from perlscript(homepage.pl), i want to add piece of html code in the footer of the homepage. I simply pasted the html code at the end of the perl script as below... ======================================================== close(OUTSQL); ... (4 Replies)
Discussion started by: paventhan
4 Replies

9. Shell Programming and Scripting

Embedding a command with SSH

Hi I am trying to run a script centrally that will go out and set the network management ip address on all my Sun boxes running Solaris. We have decided that the network management address will be the boxes main IP address but the first octet as a 172 rather than a 10, so for example ifconfig -a... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

10. Programming

Embedding xnest in C code

I hope I am posting this in the right section. I have c file that is using the motif GUI toolkit to draw widgets and things of that sort. I also have another program that runs with xnest. I need to figure out a way to place that xnest program in my c code so that it exists in the window that the... (4 Replies)
Discussion started by: lesnaubr
4 Replies
Login or Register to Ask a Question