aru Posted January 13, 2003 Report Share Posted January 13, 2003 bradenm Frequent user Joined: 01 May 2002 Posts: 69 Location: Kelowna, BC, Canada Posted: Wed May 01, 2002 7:42 pm Post subject: (newbie) Console HOWTO _________________________________________________________________ Console HOWTO: by bradenm (a work in progress, please comment) Linux revolves around the command line. There are many, many graphical tools, but they are (almost) all just interfaces to the command line. To follow this HOWTO, launch a terminal: Menu > Terminals > Shell Prompt When you are logged in, you will see something like [braden@macdonald braden]$ Here is a breakdown of what this says: [braden@macdonald braden]$ : Your user name. [braden@macdonald braden]$ : The hostname (friendly name) of the computer. [braden@macdonald braden]$ : The name of the directory you are currently in. type pwd for the full path. Changing Directory To change directory, use the cd command. Examples: To change to your home (the main directory for your user) directory: cd or cd $HOME or cd ~ (~ is automattically tranlated into /home/yourname/) To change any directory: cd /foo/blah/stuff/ To change to a directory relative to the current directory: cd music/ Listing files To list the files in the current directory, type ls (LiSt). To list the files with more details: ls -l nota bene: (Latin for note well) In Linux/UNIX all files/directories/commands are treated as case-senitive. Typing LS is different than typing ls. History Bash (the shell, the program that runs the command line) has extensive history capabilities. To see the last command you did, press [uP ARROW]. Pressing it again will view the command before that, and so on. [DOWN ARROW] is the reverse. Typing !ech will execute the last command that you did starting with "ech". (like echo Hi) Your history is stored in the file called .bash_history in your home directory. Piping To send the output of one command as the input of another, use the | operator. (Above the backslash on your keyboard.) Example: cat ~/.bash_history|grep -e echo Will list all commands you've ever entered containing the word "echo" CTRL-x presing CTRL-key will do different things: CTRL-D: logout. Same as typing exit CTRL-S: turns on "keyboard delay". Anything that you type will be stored until your press CTRL-Q Example: Press CTRL-S. Type echo hello [ENTER] . Press CTRL-Q. pineault Frequent user Joined: 09 May 2002 Posts: 32 Location: Montreal, Québec Posted: Tue May 14, 2002 2:39 pm Post subject: stupid question about command line display _________________________________________________________________ I would like to know how to control the display in a bash console window, ie when using top or ls how to control the display process so as to work in a page mode and thus be able to scroll through the posted content instead of having just the last lines displayed. bradenm Frequent user Joined: 01 May 2002 Posts: 69 Location: Kelowna, BC, Canada Posted: Tue May 14, 2002 3:28 pm Post subject: _________________________________________________________________ top|more for the output of a command like top or more filename for the contents of a file Also, you can just type top, then use shift+pageUp and shift+pageDn to scroll through the output. cannonfodder Moderator Joined: 16 Apr 2002 Posts: 1056 Location: Rochester, NY, USA Posted: Tue May 14, 2002 4:43 pm Post subject: _________________________________________________________________ So basically more README.txt (hit spacebar to scroll) cat REAMDE.txt | more (same, output gets piped to more program) less README.txt (scroll up/down whatever, hit q to quit) cat README.txt | less pineault Frequent user Joined: 09 May 2002 Posts: 32 Location: Montreal, Québec Posted: Tue May 14, 2002 6:16 pm Post subject: _________________________________________________________________ thanks pokestix Newbie Joined: 31 Oct 2002 Posts: 3 Posted: Thu Oct 31, 2002 8:05 pm Post subject: command prompt to gui _________________________________________________________________ i just installed and it is booting straight to the command prompt. how do i get to the gui? i'm sure this is a really stupid question, but i'm a stupid newb and i couldn't find the answer to this. thanks a bunch. neil spiedra Senior user Joined: 30 May 2002 Posts: 686 Location: Orlando, FL Posted: Thu Oct 31, 2002 8:18 pm Post subject: _________________________________________________________________ At the command prompt, login and type: startx pokestix Newbie Joined: 31 Oct 2002 Posts: 3 Posted: Thu Oct 31, 2002 10:06 pm Post subject: _________________________________________________________________ so simple, but so helpful...thanks a ton man! spiedra Senior user Joined: 30 May 2002 Posts: 686 Location: Orlando, FL Posted: Thu Oct 31, 2002 11:02 pm Post subject: _________________________________________________________________ No problem Smile Quote Link to comment Share on other sites More sharing options...
aru Posted January 13, 2003 Author Report Share Posted January 13, 2003 That was an example of how the backup copies of the Tips&Tricks and FAQ-Howtos from www.club-nihil.net/mub are going to be posted here. As we discused in http://www.mandrakeusers.org/viewtopic.php?t=1744, with modifications on those scripts, and some other scripts I've done tonight, I have backuped and dumped those threads into the format seen above. If no one is against I'll repost those threads here tomorow (please, notice that the work has been done while I was a bit drunk) Here are the scripts used (see the above link for a further description in how to use them): #!/bin/bash #Strips the urls from the forum indexes into TOPICS.TXT URL="www.club-nihil.net/mub/" for file in *viewforum.php.html; do echo -e $( sed -n '/.*(viewtopic.php?t=[[:alnum:]]{1,5}).*topictitle..(.*)</a><.*/ { s//ntagn# 2: tagnt'${URL}'1 tagn/g; p; } /Goto page:/ { s/(viewtopic.php?t=[[:alnum:]]{1,5})&(start=[[:alnum:]]{1,3})/ nt'${URL}'1&2 tagn/g; p; }' < ${file} ) | grep tag | grep -v 'start=0' | sed 's/tag//g' done > TOPICS.TXT #!/bin/bash #downloads the threads (using the urls stored in TOPICS.TXT) mkdir -p html cd html while read url; do if echo $url | grep -q www.club-nihil.net; then wget -E $url; fi; done < ../TOPICS.TXT [arusabal@localhost ~/backup/html]$ for i in viewtopic.php?t=*; do mv $i ${i#*=}; done [arusabal@localhost ~/backup/html]$ for i in *&start=15.html; do mv $i ${i/&*/b}.html; done [arusabal@localhost ~/backup/html]$ for i in *&start=30.html; do mv $i ${i/&*/c}.html; done [arusabal@localhost ~/backup/html]$ for i in *&start=45.html; do mv $i ${i/&*/d}.html; done #!/bin/bash # converts the thread from html format to text mode. pre_regexp='<th class="thRight" nowrap="nowrap">Message</th>' post_regexp='Display posts from previous' pre_regexp_2='postdetails' post_regexp_2='SPAN CLASS="postbody"' for file in *.html; do interm="post_${file}" sed -n "/$pre_regexp/,/$post_regexp/p" $file | sed -n "/$pre_regexp_2/,/$post_regexp_2/p" | egrep -v "${post_regexp//"/"}|Reply with quote|_________________" | sed "s/<a href=.*</a>//g; s/<img.*Joined/Joined/g; s/<b>/[b]/g; s/</b>/[/b]/g; s/(class="name">)/1<p>[color=red]/g; s/<span class="postbody">/1[/color]/g; s/^^M$/<p>/g; s/<span style="font-weight: bold">(.*)</span>/[b]1[/b]/g; " > ${interm} lynx -dump ${interm} > ${file/html/txt} rm ${interm} done The last script is a mess, I know, so feel free to modify it in order to get a better output. Quote Link to comment Share on other sites More sharing options...
ezroller Posted January 13, 2003 Report Share Posted January 13, 2003 excellent. Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 13, 2003 Report Share Posted January 13, 2003 I'm assuming that this line: rm ${interm} is supposed to delete the *.html version of the file after converting it to text (I'm new to shell scripting), but it doesn't do that when I run it. What could be my problem? Quote Link to comment Share on other sites More sharing options...
aru Posted January 13, 2003 Author Report Share Posted January 13, 2003 no, that removes an intermediate html file between the original html file, which I want to keep, and the final txt.file. If you are interested, Ive modified the last script in order to have a more formated output (bbcode): # ......... pre_regexp='<th class="thRight" nowrap="nowrap">Message</th>' post_regexp='Display posts from previous' pre_regexp_2='postdetails' post_regexp_2='SPAN CLASS="postbody"' for file in *.html; do interm="post_${file}" sed -n "/$pre_regexp/,/$post_regexp/p" $file | sed -n "/$pre_regexp_2/,/$post_regexp_2/p" | egrep -v "${post_regexp//"/"}|Reply with quote|_________________" | sed "s/<a href=.*</a>//g; s/<img.*Joined/Joined/g; s/<b>/[b]/g; s/</b>/[/b]/g; s/(class="name">)/1<p>[color=red]<p>/g; s/<span class="postbody">/1[/color]<p>/g; s/^^M$/<p>/g; s/<span style="font-size: ..px; line-height: normal">(.*)</span>/[size=18]1[/size]/g; s/<span style="font-weight: bold">(.*)</span>/[b]1[/b]/g; s/<td class="code">/[[]code]/g; " > ${interm} lynx -dump ${interm} > ${file/html/txt} #rm ${interm} done Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 13, 2003 Report Share Posted January 13, 2003 One problem with your scripts... If there is a link posted inside a post, it doesn't show up in a post....here's an example: toxaq Moderator Joined: 16 Apr 2002 Posts: 185 Location: Te Ika a Maui Posted: Thu May 23, 2002 12:57 am Post subject: Thanyes board down? _________________________________________________________________ Can some one tell me if they're getting thayne's ? (at [notice there is supposed to be a URL here]) I miss my mint green....... Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted January 13, 2003 Report Share Posted January 13, 2003 aru (and to those working on the scripts), can the backed.up threads be uploaded here in separate posts? some posts will be very long that reading through them will leave us mere mortals (and non-nuts :P ) dizzy for quite some tome. :mystismiles: ciao! Quote Link to comment Share on other sites More sharing options...
aru Posted January 13, 2003 Author Report Share Posted January 13, 2003 One problem with your scripts... If there is a link posted inside a post, it doesn't show up in a post....here's an example: toxaq Moderator Joined: 16 Apr 2002 Posts: 185 Location: Te Ika a Maui Posted: Thu May 23, 2002 12:57 am Post subject: Thanyes board down? _________________________________________________________________ Can some one tell me if they're getting thayne's ? (at [notice there is supposed to be a URL here]) I miss my mint green....... I know that, but since the urls are mainly to club-nihil's it self who cares... :? The most important thing are the contents, IMHO Quote Link to comment Share on other sites More sharing options...
aru Posted January 13, 2003 Author Report Share Posted January 13, 2003 aru (and to those working on the scripts), can the backed.up threads be uploaded here in separate posts? some posts will be very long that reading through them will leave us mere mortals (and non-nuts :P ) dizzy for quite some tome. :mystismiles: ciao! True, but that would mean a lot of work ... and since the important thing are the contents... well, the true is that I'm lazy and I'm not drunk as I was yesterday night when I started to make the scripts :P Quote Link to comment Share on other sites More sharing options...
aru Posted January 13, 2003 Author Report Share Posted January 13, 2003 One problem with your scripts... If there is a link posted inside a post, it doesn't show up in a post.... Ive ended removing the sentence in sed that deleted urls and changing the lynx command to this one, to at least show that there was an url: lynx -dump -nolist -dont_wrap_pre ${interm} > ${file/html/txt} That applies only to the tips&tricks that I'm going to upload here tonight (too late for the Faqs/Howtos), sorry :( Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 13, 2003 Report Share Posted January 13, 2003 I edited my topics.txt by replacing www.club-nihil.net/mub/ with <a href=" replaced: php?t with php%3Ft and added </a><br> to the end of each line and saved it as a new file topics.html (of course I put <html> at the beginning and </html> at the end), so now I have an html index in my directory that I can use to view the files I want (by title). I have no idea how to write a shell script to make those changes automatically. Quote Link to comment Share on other sites More sharing options...
aru Posted January 18, 2003 Author Report Share Posted January 18, 2003 Just in case someone is interested in, and to increase my post counter, here is the final script that I used to convert the html saved files into BBCode formated text files to copy and paste here: #!/bin/bash # mup_parser.sh # script to parse MUO_html pages into TEXT_files for backup purposes pre_regexp='<th class="thRight" nowrap="nowrap">Message</th>' post_regexp='Display posts from previous' pre_regexp_2='postdetails' post_regexp_2='SPAN CLASS="postbody"' for file in *.html; do interm="post_${file}" sed -n "/$pre_regexp/,/$post_regexp/p" $file | sed -n "/$pre_regexp_2/,/$post_regexp_2/p" | egrep -v "${post_regexp//"/"}|Reply with quote|_________________" | sed " s/<img.*Joined/Joined/g; s/<b>/[b]/g; s/</b>/[/b]/g; s/(class="name">)/1<p>[_remove_color=red]<p>/g; s/<span class="postbody">/1[/color]<p>/g; s/^ $/<p>/g; s/<span style="font-size: ..px; line-height: normal">(.*)</span>/[size=18]1[/size]/g; s/<span style="font-weight: bold">(.*)</span>/[b]1[/b]/g; " | awk ' { # ---------------- quote ------------------ if ( /<td class="quote">.*color/ ) # Substitues quotes with begin and end in the same line. { sub("<td class="quote">","[i]"); sub("color","i") } else if ( /<td class="quote">/ ) # Substitue quote string with [i] and increases the counter (end quote in a different line) { sub("<td class="quote">","[i]"); ++count_quot } else if ( count_quot > 0 && /color/ ) # Closes quote as replacing "[/color]" with "[/i]" # y el valor del contador. { sub("color","i"); --count_quot }; # ---------------- code ------------------- if ( /<td class="code">.*color/ ) { sub("<td class="code">","[_remove_code]"); sub("color","code") } else if ( /<td class="code">/ ) { sub("<td class="code">","[_remove_code]"); ++count_code } else if ( count_code > 0 && /color/ ) { sub("color","code"); --count_code }; print; } ' > ${interm} lynx -dump -nolist ${interm} > text/${file/html/txt} rm ${interm} done remember to remove the "_remove_" string before testing the above code ... and to copy and paste quickly the tips&tricks backups --as I didn't knew how to handle the cookies of this site-- I used this script alongside with opera: #!/bin/bash # pseudo bot. # open opera and log into Mub; then launch this script. for file in text/*.txt; do htmlpage=test/${file##*/}.html subject="Tips&Tricks $(head -12 $file|sed -n '/.*Post subject:(.*)/ {s//1/g;p;}')" cat > $htmlpage <<- EOF <html> <form action="http://www.mandrakeusers.org/posting.php" method="post" name="post" onsubmit="return checkForm(this)"> <table><tr> <input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="${subject}" /> </tr><tr> <textarea name="message" rows="30" cols="100" wrap="virtual" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">$(cat ${file})</textarea> </tr><tr> <input type="checkbox" name="attach_sig" checked="checked" /> </tr><tr> <input type="hidden" name="mode" value="newtopic" /><input type="hidden" name="f" value="22" /><input type="submit" tabindex="5" name="preview" class="mainoption" value="Preview" /> <input type="submit" accesskey="s" tabindex="6" name="post" class="mainoption" value="Submit" /> </tr></table></form> </html> EOF opera -remote "openURL($PWD/$htmlpage,new-page)" mv $file sent/ sleep 25 done Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.