Script not working as desired


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script not working as desired
# 15  
Old 07-25-2006
Reborg,

It's not writing the data to the CARE01_DLY_20060725 file but it created one file with name CARE01_DLY_AUS_20060725_new with one line of data.

Please see output from below:

3
7
3 11 7
awk: A print or getline function must have a file name.
The input line number is 5. The file is CARE01_DLY_MKT_20060725.
The source line number is 24
# 16  
Old 07-25-2006
I've updated the code in Post #14...got rid of the debug, and added the quotes I'd forgotten around the filename.
# 17  
Old 07-25-2006
Reborg,

You are simply great man!!!! Smilie

I just changed the code so that I am not hard coding the name of the final file. Please let me know if this works. I am just including the changed portion here from post#14

Quote:
print data[i] > "${1}_$(date +%Y%m%d)"
Will this work?

I want to just let you know that I call the script like this satya.ksh CARE01_DLY

I just want to let you know that I have become your fan. Smilie
# 18  
Old 07-25-2006
Reborg,

It created the file with name ${1}_${date+%Y%m%d). I should have kept single quotes i guess. Kindly suggest.
# 19  
Old 07-25-2006
#14 updated again.
# 20  
Old 07-25-2006
Reborg,

It created the file CARE01_DLY_ The date portion is missing though. Are we missing any where?
# 21  
Old 07-25-2006
Reborg,

It's working!!!!! I have changed that to what Vgresh has suggested in earlier posts. It's working now.

changed portion here:

Quote:
awk -v complete_file=${1}_$(date+%Y%m%d) 'FNR != 1 {
to

Quote:
awk -v complete_file=${1}_`date '+%Y%m%d'` 'FNR != 1 {
Once again I am learning a lot from this wonderful site!!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need comand or script for append text after searching for the desired string

Hi all, i have a generated report in unix in the following command like input.txt 47.85,10 0124,42.35,8 0125,3.5,2 the input file format is fixed I need the my output file with append text as below output.txt 0124 amount:42.35 0125 amount:3.5 0124 count : 8 0125... (34 Replies)
Discussion started by: hemanthsaikumar
34 Replies

2. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

4. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

5. Shell Programming and Scripting

Cron job is not working in the desired manner on IBM AIX

Hi, I have created a cron job on IBM AIX but it is not working in desired manner ! Here are the steps which I have followed :- #!/bin/ksh #------------------------------------------------------------------ find /some/file/at/the/user/side/test.log -exec cp {}... (8 Replies)
Discussion started by: acidburn_007
8 Replies

6. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. UNIX for Dummies Questions & Answers

if statement not working as desired

Hello all, I am trying to write a post-commit hook script using bash script. What I am trying to do here is: Developers check in their files to a branch. I check the repository and based on the commit I email QA people. QA verifies and moves the files to a prod branch and email is sent... (1 Reply)
Discussion started by: kminkeller
1 Replies

8. Shell Programming and Scripting

C shell integer tests, less than and more than, not working as desired

Hello, I am creating a script that gives me system load info when i start a shell or log in via ssh(in the /etc/profile.d/ folder). I created it successfully for bash and want it to work with c-shell as well. This is where i'm having problems, the integer test in the if sentence does not work... (3 Replies)
Discussion started by: str1fe
3 Replies

9. Shell Programming and Scripting

script not giving the desired output

Hi, I have a script in which an entry like this ..... FILENAME_B="PIC_${DATE}0732*.JPG" The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM. Means 1st 8 digit is the date(YYYYMMDD) field 2nd 8 digit means hrs... (2 Replies)
Discussion started by: Renjesh
2 Replies

10. UNIX for Dummies Questions & Answers

chmod not working as desired

my file had permission -rw-rw-r-- I did chmod +rwx, expecting everything to now be rwx, but it is -rwxrwxr-x why doesn't o have x permission? thanks. (2 Replies)
Discussion started by: JamesByars
2 Replies
Login or Register to Ask a Question