Solved

from tclsh to tcsh

Posted on 1998-03-24
7
788 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Question regarding Copy/Paste 16 87
java ^ examples 8 57
wordcount challenge 11 78
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now