Solved

from tclsh to tcsh

Posted on 1998-03-24
7
802 Views
Last Modified: 2013-12-26
I got two small script that needs to be converted to tcsh could anyone help me?

#!/usr/bin/tclsh

if {$argc !=2} {
error "Usage: firstscript infileName Outfilename"
}

set fin [open [lindex $argv 0] r]
set fout [open [lindex $argv 1] w]
set a ":Bibelords prenumerant"

while {[gets $fin line] >= 0} {
set line $line$a
puts $fout $line
}
close $fout
close $fin

#!/usr/bin/tclsh

if {$argc !=2} {
 error "Usage: firstscript infileName Outfilename"
}

set fin [open [lindex $argv 0] r]
set fout [open [lindex $argv 1] w]
set a \&email\=
set b \&name\=

puts $fout \[begin\]

while {[gets $fin line] >= 0} {
 regsub -all : $line \n line
 set c [lindex $line 0]
 regsub -all $c $line \0 line
 regsub -all \n $line \0 line
 set line $a$c$b$line
 puts $fout $line
}

close $fout
close $fin

0
Comment
Question by:jonasm
  • 5
  • 2
7 Comments
 

Author Comment

by:jonasm
ID: 1296185
Adjusted points to 300
0
 
LVL 84

Expert Comment

by:ozo
ID: 1296186
#!/usr/local/bin/tcsh -f

if $#argv != 2 then
   echo "Usage: firstscript infileName Outfilename"
   exit
endif

perl -pe 's/$/:Bibelords prenumerant/' < $1 >! $2

#!/usr/local/bin/tcsh -f

if $#argv != 2 then
   echo "Usage: firstscript infileName Outfilename"
   exit
endif

echo '[begin]' >! $2
perl -ape 's/^s+//;s/$F[0]//g;print"&email=$F[0]&name="' $1 >> $2


0
 

Author Comment

by:jonasm
ID: 1296187
Adjusted points to 400
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 84

Expert Comment

by:ozo
ID: 1296188
Oops, didn't notice that
 regsub -all : $line \n line
This may be a little closer
 perl -ape 's/\s*((\\.|[^\s:])+)/$1/; ($c=$1)=~s/\\:/ /g; s/$c//g; tr/://d; print"&e\mail=$c&name="' $1 >> $2

but do you really mean to say
 regsub -all $c $line \0 line
That seems to do interesting things when $fin contains lines like
1\:(.)2      1 1234
which I'm not sure I understand enough tclsh to know how to duplicate exactly,
and which I'm not sure you want to duplicate exactly
0
 
LVL 84

Expert Comment

by:ozo
ID: 1296189
jonasm, are we on the right track or not?
Without some feedback I can't guess which aspects of the tclsh script behavior need to be duplicate exactly, which are bugs you don't really want to duplicate, and which are just ideosyncracys that you don't care about since you never run into those situations anyway.
0
 
LVL 84

Accepted Solution

by:
ozo earned 400 total points
ID: 1296190
I'm guessing then that the Adjusted points to 400 must have been intended to be given in acceptance of the original answer...

#!/usr/local/bin/tcsh -f
if $#argv != 2 then
    echo "Usage: firstscript infileName Outfilename"
    exit
endif
perl -pe 's/$/:Bibelords prenumerant/' < $1 >! $2


#!/usr/local/bin/tcsh -f
if $#argv != 2 then
    echo "Usage: firstscript infileName Outfilename"
    exit
endif
echo '[begin]' >! $2
perl -ape 's/\s*((\\.|[^\s:])+)/$1/; ($c=$1)=~s/\\:/ /g; s/$c//g; tr/://d; print"&email=$c&name="' $1 >> $2

0
 
LVL 84

Expert Comment

by:ozo
ID: 1296191
jonasm, if those scripts do what you wanted, please grade the answer.
If you wanted something else, please reopen the question, and add an explaination of what you would like the scripts to do differently.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 87
centeredAverage challenge 8 181
Unix Command -- Challenging  question 7 96
Way to decrease size of apk file 9 88
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question