LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-27-2005, 03:19 AM   #1
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
Convert shell scripts to other language


Hello,

Does anybody knows a tool to convert a bash shell script to other languages. My problem is that a small script grew and now must generate a lot of ouput in many files, and bash is to slow for that.

(I could rewrite it but thought it was woth asking)

Thanks,
 
Old 07-27-2005, 04:53 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
Even if such a tool exits, the resulting code wouldn't be optimized...
Also you may find that rewrite your code is faster than searching
the code converter tool
 
Old 07-27-2005, 04:56 AM   #3
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 30
Something like this http://www.datsi.fi.upm.es/~frosal/sources/shc.html ?

EDIT: keefaz is right in the optimization observation, I think.

Last edited by enemorales; 07-27-2005 at 04:57 AM.
 
Old 07-27-2005, 05:13 AM   #4
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Original Poster
Rep: Reputation: 33
enemorales:
Thanks, I will give it a try
Edit: from the man page: shc's main purpose is to protect your shell scripts from modification or inspection.


keefaz:
Only the first time will take longer.

And even if it will not be optimised I think it will run much faster in C or perl. One benchmark I found (not that relevant but still there is a huge difference shown) http://www1.physik.tu-muenchen.de/~j...uagebench.html - bash/perl performance is 600x so I think even 'unoptimized' code will run fast.

Last edited by vladmihaisima; 07-27-2005 at 05:14 AM.
 
Old 07-27-2005, 06:15 AM   #5
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 30
Quote:
enemorales:
Thanks, I will give it a try
Edit: from the man page: shc's main purpose is to protect your shell scripts from modification or inspection.
Well, tha's what I meant. I think that the program just does

Code:
main() {
  system("....") /* your first shell statement */
  system("...")  /* second shell statement */
  ...
}
in a kind of "encrypted" way, but as it is using the shell, it cannot be faster than the script.

As keefaz said, I think that the better you can do is to rewrite your script(s) in perl or python.

Regards
 
Old 07-27-2005, 08:52 AM   #6
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
[edit]
just tested shc, indeed the script shell is encrypted in the binary

Last edited by keefaz; 07-27-2005 at 08:58 AM.
 
Old 07-28-2005, 02:25 AM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Generally I'd have to agree a re-write is prob best.
For one thing, if the script 'just grew' then it will prob benefit from a re-design anyway.
Also, as an aside, Perl comes with these 2 tools: awk2perl, sed2perl. Maybe useful (or not).
 
  


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
How to convert Assembly langugae to Executable in c language ssg14j Programming 15 11-04-2008 07:49 AM
difference between shell scripting and c language gadekishore Linux - Software 5 10-17-2005 06:33 AM
Change shell language linmix Linux - Software 9 07-26-2004 12:45 PM
Howto convert Gentoo wlan scripts to Debian? Naughtyus Debian 1 02-25-2004 03:55 PM
What is the best language for Linux/Apache Scripts? 360 Programming 3 09-16-2001 09:13 PM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration