Solved

from tclsh to tcsh

Posted on 1998-03-24
7
803 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
Adapt this command to show who installed 29 114
Looking for a specific application/software 2 124
Detect CR LF to each line 12 185
sumNumber challenge 16 147
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

759 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