Solved

from tclsh to tcsh

Posted on 1998-03-24
7
809 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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