Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

from tclsh to tcsh

Posted on 1998-03-24
7
Medium Priority
?
827 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 85

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
Independent Software Vendors: 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 85

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 85

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 85

Accepted Solution

by:
ozo earned 1200 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 85

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

Industry Leaders: 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!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Integration Management Part 2
Suggested Courses

916 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