Please translate this debian bash file into csharp.

Need help with C, C++, perl, python, etc?

Please translate this debian bash file into csharp.

Postby b4w » 2015-12-16 23:40

Or at least give me sample csharp code to call debian functions? I do not know csharp, this project is to help me learn. I will compile code with gmcs; I will run code with mono;

Code: Select all
echo "bash ebook/bash/Alice.txt This Debian bash file converts project gutenberg, from http://www.gutenberg.org/cdproject/pgdvd042010.iso.torrent, pgdvd042010/1/11/11.ZIP Alices Adventures in Wonderland into audio files. 406mb.";

echo "install required packages. requires root privledge.";
# apt-get install --allow-unauthenticated -y rpl csplit espeak sox;

echo "define path.";
# ${IN} origional zip file location.
IN="pgdvd042010/1/11/11.ZIP";
# ${OUT} put everything into this location, to be overwriten.
OUT="ebook/Alice/";
echo ${IN} ${OUT}; rm -r ${OUT}; mkdir -p ${OUT};

echo "unzip origional file to its default filename."; cp ${IN} ${OUT}; unzip ${OUT}11.ZIP -d ${OUT};
echo "create shadow file to modify."; cp ${OUT}11.txt ${OUT}shadow.txt;
echo "remove items not appropiate for speech."; rpl "*" " " ${OUT}shadow.txt;
echo "split book into chapters."; mkdir ${OUT}text/; csplit ${OUT}shadow.txt -f${OUT}text/ -b%.2d'.txt' "/CHAPTER/" {11} "/End of/";

echo; echo -n "convert txt to wav"; mkdir ${OUT}wav/;
for i in {01..12}; do echo -n " $i"; espeak -f ${OUT}text/$i.txt -w ${OUT}wav/$i.wav; done

echo; echo -n "convert wav to ogg"; mkdir ${OUT}ogg/;
for i in {01..12}; do echo -n " $i"; sox ${OUT}wav/$i.wav ${OUT}ogg/$i.ogg; done

cp ebook/bash/Alice.txt ${OUT}bash.txt;
ls ${OUT} > ${OUT}log.txt; ls ${OUT}*/ >> ${OUT}log.txt; ls ${OUT}*/*/ >> ${OUT}log.txt;

echo "end";
# play ${OUT}ogg/01.ogg;
b4w
 
Posts: 21
Joined: 2015-08-04 19:06

Re: Please translate this debian bash file into csharp.

Postby dasein » 2015-12-17 00:24

b4w wrote:...this project is to help me learn

Then you really ought to start by at least trying a simple Web search. (No big surprise, you are not the first person on Planet Earth to want to do something like this.)

Asking someone to convert the code for you teaches you nothing.
User avatar
dasein
 
Posts: 7267
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Please translate this debian bash file into csharp.

Postby kiyop » 2015-12-17 12:43

Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
User avatar
kiyop
 
Posts: 3983
Joined: 2011-05-05 15:16
Location: Where persons without desire to improve themselves fear to tread, in Japan

Re: Please translate this debian bash file into csharp.

Postby runfrodorun » 2016-01-10 17:51

Honestly seems like something that should be done in bash or similar, that's a very non-trivial task accomplished trivially using some of the wonderful tools and features of unixlike userlands. Could I perhaps interest you in a non-microsoft developed language? Perhaps a cup o java? Yeah don't learn java either.

-RJ
Much opinionated.
Some abrasive.
No systemd.
Wow.
runfrodorun
 
Posts: 195
Joined: 2013-06-19 05:09

All done. g++ used.

Postby b4w » 2016-08-10 17:47

Code: Select all
#include <iostream>
#include <cstdio>
#include "stdio.h"
#include "stdlib.h"
using namespace std;

int main(){

cout <<"g++ -o a2.exe a2.cc; chmod a+x a2.exe; a2.exe; This progam converts project gutenberg from http://www.gutenberg.org/cdproject/pgdvd042010.iso.torrent pgdvd04/1/11/11.ZIP Alices Adventures in Wonderland into audio files. 406mb\n";

cout << "define path\n";
const char* sourcePath="/mnt/pgdvd042010/1/11/11.ZIP";
const char* destPath="test2/";
const char* stmp1 = "rm -r destPath";
const char* stmp2 = "mkdir -p destPath";
const char* stmp3 = "mkdir destPath/wav";
const char* stmp4 = "mkdir destPath/ogg";
cout << sourcePath<<" "<<destPath<<"\n";
system(stmp1); system(stmp2); system(stmp3); system(stmp4);


system("cp /mnt/pgdvd042010/1/11/11.ZIP destPath");

cout <<"unzip original file to its default filename\n";
system("unzip ebook/alice/11.ZIP -d destPath");

cout <<"create shadow file to modify\n";
system("cp ebook/alice/11.txt destPath/shadow.txt");

cout << "remove items not appropriate for speech\n";
system("rpl \"'\" \" \" destPath/shadow.txt");
system("rpl '*' ' ' destPath/shadow.txt");

cout <<"split book into chapters\n";
system("mkdir destPath/text/");
system("csplit ebook/alice/shadow.txt -f ebook/alice/text/ -b%.2d'.txt' \"/CHAPTER/\" {11} \"/End of/\"");

cout <<"convert txt to wav\n";
system(stmp3);
for(int i =0;i<14;i=i+1){
char buf[100];
sprintf(buf,"espeak -f ebook/alice/text/%02d.txt -w ebook/alice/wav/%02d.wav",i,i);
system(buf);
printf("%d\n",i);
}

cout <<"convert wav to ogg\n";
system(stmp4);
for(int i =0;i<14;i=i+1){
char buf[100];
sprintf(buf,"sox  ebook/alice/wav/%02d.wav  ebook/alice/ogg/%02d.ogg",i,i);
system(buf);
printf("%d\n",i);
}

cout <<"END\n";


}
b4w
 
Posts: 21
Joined: 2015-08-04 19:06

Re: Please translate this debian bash file into csharp.

Postby tomazzi » 2016-08-10 18:57

All done. g++ used.

Oh, really?

I have better one:
Code: Select all
int main() {
   system("bash the_script.sh");
}

Done. No need to use C++. There's no need to even write any program, since there's already one: bash :LOL:
... and You have just made a crippled version of it.

Apparenlty You have no idea what does it mean to "translate" the code from one language to another.

The translation in this case would mean that f.e. the program will directly use the dpkg API (libdpkg) to install the packages - just like this done in Synaptic.

Regards.
Odi profanum vulgus
tomazzi
 
Posts: 730
Joined: 2013-08-02 21:33


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable