LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-21-2004, 08:34 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question ksh->Tcl conversion guidelines


I'm trying to determine the syntax change rules necessary for executing ksh commands as Tcl 'exec' commands.

Here's some conversion rules that I have proven, if anyone has any more info ( in any fashion ) , please advise.

-----------------------------------------------------------------
Rule: Remove "
-----------------------------------------------------------------
ksh: cat *.passwd 2>/dev/null | cut -d":" -f1 | sort | uniq
tcl: exec cat *.passwd 2>/dev/null | cut -d: -f1 | sort | uniq
-----------------------------------------------------------------

-----------------------------------------------------------------
Rule: Replace '(..$1..)' with "{..\$1..}"
-----------------------------------------------------------------
ksh: ps -eaf | awk '(print $1}' | grep $1 2>&1
tcl: exec ps -eaf | awk "{print \$1}" | grep $user_login_to_test
-----------------------------------------------------------------

-----------------------------------------------------------------
Rule: Replace "..." with {...}
-----------------------------------------------------------------
ksh: grep "^$(user_login:" /etc/passwd /etc/shadow 2>&1
tcl: exec grep {^$user_login:} /etc/passwd /etc/shadow
-----------------------------------------------------------------

-----------------------------------------------------------------
Rule: Replace '...' with "..." or {...}
-----------------------------------------------------------------
ksh: grep 'Version' user.tcl
tcl: exec grep {Version} user.tcl
tcl: exec grep "Version" user.tcl
-----------------------------------------------------------------




Last edited by liguorir; 04-21-2004 at 09:46 PM.
 
Old 04-21-2004, 09:32 PM   #2
liguorir
Member
 
Registered: May 2003
Posts: 256

Original Poster
Rep: Reputation: 30
Question ksh -> Tcl Conversion Notes

------------------------
ksh -> Tcl
------------------------
' ' --> " " or { }

{ } --> " "

" " --> { }

( ) --> { }

"$1" --> "\$1"

{$2} -->

[ ] --> [ ]


Is this right?

Please advise.

Last edited by liguorir; 04-21-2004 at 09:34 PM.
 
Old 04-21-2004, 11:10 PM   #3
cetialphav
Member
 
Registered: Sep 2003
Location: Raleigh, NC, USA
Distribution: Fedora
Posts: 88

Rep: Reputation: 16
Most of these rules don't really look right to me. In fact, some of them are just totally broken. To get the best results with the least amount of work, try something like this:

Code:
exec sh -c {your commands here}
So do this:

Code:
cat *.passwd 2>/dev/null | cut -d":" -f1 | sort | uniq

exec sh -c {cat *.passwd 2>/dev/null | cut -d":" -f1 | sort | uniq}
The only thing to remember then is that {} is used for quoting so you have to be careful if you have to pass one of those characters in the shell command.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is my /bin/ksh ']['HeBroken Linux - Software 2 03-11-2006 04:25 PM
The ksh command Gins Linux - General 10 11-20-2004 06:56 PM
Can somebody help me with a ksh script? twentymil AIX 7 01-21-2004 09:55 AM
KSH script AquamaN Programming 2 12-08-2003 11:34 AM
some ksh scripting nabil Programming 1 03-03-2002 10:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration