Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unable to write to a file within a loop Post 302471769 by janardhanamk on Monday 15th of November 2010 04:44:08 AM
Old 11-15-2010
Unable to write to a file within a loop

Hi All,

Following is the program that i have written in cygwin. The redirection of the unfound $param1 to error.txt file doesnt work.Can any one help?

Code:
 
#!/usr/bin/sh
fname=$1
sed 's/ //g' "$fname" > fname1
while read i
do
    echo $i > file1
    #param1 is script name
    param1=`awk -F , '{print $1}' file1`
    param1="$param1.sql"
    #param2 is BL
    param2=`awk -F , '{print $2}' file1`
    #param3 is folder name
    param3=`awk -F , '{print $3}' file1`
    #create config spec file
    echo "element * $param2" > cs.txt
    echo "element * /main/LATEST" >> cs.txt
    #cat cs.txt
    #create directory structure
    mkdir -p "$param3"
    #Map UCM drive
    cd /cygdrive/m/ht62_ucm/GIS_COMP
    cleartool setcs -tag ht62_ucm d:/prj/cs.txt
    echo set config spec status is $?
    fscript1=`cleartool find ./$param3 -element "lbtype_sub($param2)" -name $param1 -print`
    if [ "$fscript1" = "" ]
    then
	echo script $param1 not found >> error.txt
    else
	echo script $param1 is found
	fscript2=`echo "$fscript1" | sed 's/@@//g'`
	echo copying file...
	cp $fscript2 "/cygdrive/d/prj/$param3" 2>/dev/null
    fi
    cd /cygdrive/d/prj
done < fname1
echo Copy complete


Last edited by pludi; 11-15-2010 at 05:59 AM.. Reason: fixed indentation
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop through file and write out lines to file(s)

Hi, I am new to ksh scripting so your help will be much appreciated. I have a file called file.txt which looks like this Header 20050702 20050703 ABC DEF Header 20050703 20050704 123 456 Header 20050704 20050705 XXX YYY What I am trying to do is write out each of the record... (7 Replies)
Discussion started by: Jtrinh
7 Replies

2. Shell Programming and Scripting

trying to write a script to loop through a port info file

Below is part of a script i have written to loop through part of a port info file. How do i continue the script to get info for OS Device Name, manufacturer and then put information into an array? HBA Port WWN: 10000000c9420b4b OS Device Name: /dev/cfg/c10 Manufacturer: Emulex... (5 Replies)
Discussion started by: rcon1
5 Replies

3. Shell Programming and Scripting

help needed .. Unable to write the data to new file after matching the pattern

Hi, i am pretty new to Unix environment ..... Can i get some help from any of you guyz on writing Unix script. my requirement is like reading a csv file, finding a specific pattern in the lines and repalce the string with new string and write it to another file. My file is file ABC123.dat... (3 Replies)
Discussion started by: prashant_jsw
3 Replies

4. Shell Programming and Scripting

Push records to array during implicit loop and write to file

NEWBIE ALERT! Hi, I'm 1 month into learning Perl and done reading "Minimal Perl" by Tim Maher (which I enjoyed enoumously). I'm not a programmer by profession but want to use Perl to automate various tasks at my job. I have a problem (obviously) and are looking for your much appreciated help.... (0 Replies)
Discussion started by: jospan
0 Replies

5. Programming

unable to send read and write serial port

hey frns pls help me out !! i hav a code of c that i have to include in my project. i am using a device (geomeda) that has unix based OS. it also support SIM card for connecting to server . I need to send SMS to user from this device.. below code is not working .. i am unable to send sms and the... (7 Replies)
Discussion started by: yashwantkumar
7 Replies

6. Red Hat

Unable to write files on a filesystem

hi mounted filesystem is 50% and appropriate permissions were there but im still unable to write files ? (3 Replies)
Discussion started by: rajeshz
3 Replies

7. UNIX for Dummies Questions & Answers

Unable to write to a mounted NFS share

Hi All, I created a nfs share in the server(Solaris 10) with the following command and also updated the dfstab file share -F nfs -o rw=server_name2,anon=0 /to_share And then in the client(solaris 10) added the following command to mount the share mount -F nfs server_name1:/to_share... (4 Replies)
Discussion started by: Rossdba
4 Replies

8. UNIX for Dummies Questions & Answers

Write a while loop inside for loop?

I'm taking a unix class and need to countdown to 0 from whatever number the user inputs. I know how to do this with a while or until loop but using the for loop is throwing me off.... I know I can use an if-then statement in my for loop but can I include a while loop in my for loop? (3 Replies)
Discussion started by: xxhieixx
3 Replies

9. Shell Programming and Scripting

Unable to compare to a previous value of a variable in a while loop for a file

Hello All, I'm working on a script that will actually read a file consisting of data like the below:(ReportID,Sub_reportID,Sub_reportName) 1,1,ABC 1,2,DEF 1,3,GHI 2,1,JKL 2,2,MNO 3,1,PQR I want to read the Sub Report details for a Report_ID using while loop and write these values into... (6 Replies)
Discussion started by: venkat_reddy
6 Replies

10. HP-UX

Unable to write to NFS mounted directory

Hi, I have exported a few nfs mounts from one server to the nfs clients. This is my nfs server dfstab : # cat /etc/dfs/dfstab # place share(1M) commands here for automatic execution # on entering init state 3. # # share <pathname> # .e.g, # share -F... (3 Replies)
Discussion started by: anaigini45
3 Replies
txt2pdbdoc(1)						      General Commands Manual						     txt2pdbdoc(1)

NAME
txt2pdbdoc - Text to Doc file converter for Palm Pilots SYNOPSIS
txt2pdbdoc [-b] [-c] [-v] document-name file.txt file.pdb txt2pdbdoc -d [-D] [-v] file.pdb [ file.txt ] txt2pdbdoc -V DESCRIPTION
txt2pdbdoc converts a plain text file to a Doc(4) file in PDB (Pilot Database) format used by all models of the Palm Pilot. (It can also convert a Doc file to plain text.) Resultant PDB files can be downloaded directly to a Pilot during a HotSync. The document-name is used in the Document List view of a Doc reader application on the Pilot. OPTIONS
-b Ordinarily, characters with an ASCII code less than 9 are removed and both carriage-returns and form-feeds are converted to newlines. This option suppresses that behavior. -c Ordinarily, text is compressed. This option suppresses compression. -d Decode the given Doc file to text either to a file or to standard output if no file is specified. -D Do not check the file type/creator of the file to decode. This option should be specified only if you know for sure that the file is in fact some sort of Doc file. Attempting to decode non-Doc files will result in undefined behavior and quite possibly crash. -v Verbose mode. For encoding, print progress and compression statistics per 4K of text to standard error as well as overall statistics when completed; for decoding, print progress in a ``countdown'' style. -V Print the version number of txt2pdbdoc to standard output and exit. EXAMPLE
To convert a text file to Doc file: txt2pdbdoc 'Through the Looking Glass' alice.txt alice.pdb EXIT STATUS
Exits with one of the values given below: 0 Success. 1 Error in command-line options or use. 2 Unable to open source file. 3 Unable to open destination file. 4 Unable to read file. 5 Unable to write file. 6 File is not a Doc file. 7 Doc file uses unknown compression type. CAVEATS
1. Document names are limited to 31 characters in PDB format. Longer names are truncated but have the 29-31st characters replaced by ``...'' to indicate truncation. 2. The command isn't called ``txt2doc'' to avoid confusion about possibly having anything to do with Microsoft Word documents that use the .doc extension. SEE ALSO
html2pdbtxt(1), pdbtxt2html(1), doc(4), pdb(4) AUTHOR
Paul J. Lucas <pauljlucas@mac.com> txt2pdbdoc January 21, 2005 txt2pdbdoc(1)
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy