#!/bin/bash #----------------------------------------------------------- # re_store_present v4 # by jwm-art.net # # scrolls two messages posted on netbehaviour discussing # the usage of code in an artistic context... and this # file vertically... # # this script is for Linux systems running BASH # (run this script in a terminal...) # #----------------------------------------------------------- # clear the terminal display clear # reset cursor contains an escape-sequence which # resets the cursor position to the top-left of # the terminal when displayed via the echo -e command. reset_cursor="\033[0;0H"; erase_line="\033[0K"; v_scroll_lines=8 width=80 glitch=0 gpar=$1 wpar=$1 wparv=$2 if [ "x$1" == "x-glitch" ]; then erase_line="xxxx" wpar=$2 wparv=$3 fi if [ "x$wpar" == "x-width" ]; then # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html if [ $wparv -eq $wparv 2> /dev/null ]; then width=$wparv fi gpar=$3 fi if [ "x$gpar" == "x-glitch" ]; then erase_line="xxxx" fi # below are the message in a secret coded form. # the tr command was used on the original message # and the output cut+pasted into this script. secret_msg1=".......... I xjti puifs qfpqmf xpvme qvu vq uijoht mjlf uijt - I'n gbtdjobufe cy ipx nvdi jt sfwfbmfe uispvhi qspnqu rvpuft, tpguxbsf evnqt, bmm uif efcsjt bspvoe xibu xf dsfbuf. Iu't sfbmmy ufbtjoh uif ivnbo/nbdijof joufsgbdf joup b upubmmy ejggfsfou ejsfdujpo. A cppl pg uiftf uijoht xpvme cf xpoefsgvm........... Aoe gps uiptf xip dpvmeo'u sfbe uif dpnnboet? Ewfo jg ypv dbo, jg gps fybnqmf ypv tby l:> obop {y} - xip xpvme sfbmmy lopx xibu't _jo_ y? Bvu b siyuin jt ftubcmjtife - uibu't usvf jo cpui pvs dbtft I uijol, boe qspcbcmy xjui boypof fmtf xip xpslt uijt xby........... I sfbe ny fnbjm jo qjof (4.64) boe Gnbjm xifo I ibwf up - boe xbt uijoljoh uif puifs eby - qjof tffnt jotuboubofpvt uibolt up qbojy.dpn - hnbjm I'n bmxbyt xbjujoh, ju tuvuufst, ofwfs gffmt nvdi mjlf b dpowfstbujpo, bmuipvhi dibu't ejggfsfou pg dpvstf........... - Ambo.........." secret_msg2="..........My dvssfou bshvnfou dpodfsojoh uif ejtqmby pg dpef (bt pqqptfe up pomy uif qspdftt/pvudpnf) jt uibu uif gbdu uibu uif dpef dpoubjot jogpsnbujpo uibu jt ejsfdumy sfmbujwf up b dpodfquvbm sfbejoh pg uif xpsl, jt joftdbqbcmf. Tif qspcmfn, po uif puifs iboe, jt uibu qfpqmf xip epo'u sfbe dpef, tffn up ibwf b hfofsbm bwfstjpo up cfjoh qvu jo uibu qptjujpo (xifsf uify nvtu bdlopxmfehf uif dpef). Tijt jt tpnfuijoh xf offe up ifmq qpufoujbm bvejfodft up pwfsdpnf. Ppjoujoh pvu mjuumf uijoht ifsf boe uifsf xjmm ifmq up tipx uibu ju't opu bt dpnqmjdbufe bt nptu opo-dpefst uijol. Wsjujoh dpef dbo cf b dpnqmjdbufe qspdftt cfdbvtf ju ibt up xpsl cvu sfbejoh dpef jt bmuphfuifs ejggfsfou boe ypv epo'u offe up lopx ipx up xsjuf dpef up cf bcmf up sfbe dpef. Np npsf uibo ypv offe up cf bcmf up xsjuf b cppl up sfbe b cppl ps qbjou b qbjoujoh up sfbe b qbjoujoh. Tijt xibu xf offe up nblf lopxo...........cftu s, Pbmm.........." ## used to convert (an already escaped) history ## list... encloses each line in double quotes.. #src_line_count=`cat history_escaped | wc -l` #src_line=1 #while [ "$src_line" -lt "$src_line_count" ] #do # # get line $src_line from file: # ln=`head -n $src_line history_escaped | tail -n 1` # echo " \"${ln:0:80}\"" >> src_hist_esc # let src_line=src_line+1 #done #exit hist_arr=( " 318 \$m=\"Hello WOrld\";echo \${m:4}" " 319 \$m=\"Hello WOrld\";" " 320 m=\"Hello WOrld\";echo \${m:4}" " 321 m=\"Hello WOrld\";echo \${m:0:4}" " 322 m=\"Hello WOrld\";echo \${m:0:1}" " 323 m=\"Hello WOrld\"; l=\${#m}; echo \${m:0:l}" " 324 m=\"Hello WOrld\"; l=\${#m}; echo \${m:0:l-1}" " 325 m=\"Hello WOrld\"; l=\${#m}; echo \${m:0:1}" " 326 m=\"Hello WOrld\"; l=\${#m}; echo \${m:0:l-1} \${m:0:1}" " 327 m=\"Hello WOrld\"; l=\${#m}; echo \${m:1:l-1} \${m:0:1}" " 328 m=\"Hello WOrld\"; l=\${#m}; echo \${m:1:l-1}\${m:0:1}" " 329 Downloads/re_store_present " " 330 echo \${\"Hello\":0:1}" " 331 \$m" " 332 echo \${m:0:1}" " 333 l" " 334 l=\${#m}" " 335 echo \$l" " 336 echo \${m:1:l-1}" " 337 Downloads/re_store_present " " 338 clear" " 339 Downloads/re_store_present " " 340 echo \"My current argument concerning the display of code (as opposed to " " 341 the process/outcome) is that the fact that the code contains" " 342 information that is directly relative to a conceptual reading of the" " 343 work, is inescapable. The problem, on the other hand, is that people" " 344 who don't read code, seem to have a general aversion to being put in" " 345 that position (where they must acknowledge the code). This is" " 346 something we need to help potential audiences to overcome. Pointing" " 347 out little things here and there will help to show that it's not as" " 348 complicated as most non-coders think. Writing code can be a" " 349 complicated process because it has to work but reading code is" " 350 altogether different and you don't need to know how to write code to" " 351 be able to read code. No more than you need to be able to write a book" " 352 to read a book or paint a painting to read a painting. This what we" " 353 need to make known.\" | tr a-x b-z" " 354 echo \"My current argument concerning the display of code (as opposed to " " 355 the process/outcome) is that the fact that the code contains" " 356 information that is directly relative to a conceptual reading of the" " 357 work, is inescapable. The problem, on the other hand, is that people" " 358 who don't read code, seem to have a general aversion to being put in" " 359 that position (where they must acknowledge the code). This is" " 360 something we need to help potential audiences to overcome. Pointing" " 361 out little things here and there will help to show that it's not as" " 362 complicated as most non-coders think. Writing code can be a" " 363 complicated process because it has to work but reading code is" " 364 altogether different and you don't need to know how to write code to" " 365 be able to read code. No more than you need to be able to write a book" " 366 to read a book or paint a painting to read a painting. This what we" " 367 need to make known.\" | tr a-x b-z" " 368 echo \"secret_msg2=\"My current argument concerning the display of code (" " 369 the process/outcome) is that the fact that the code contains" " 370 information that is directly relative to a conceptual reading of the" " 371 work, is inescapable. The problem, on the other hand, is that people" " 372 who don't read code, seem to have a general aversion to being put in" " 373 that position (where they must acknowledge the code). This is" " 374 something we need to help potential audiences to overcome. Pointing" " 375 out little things here and there will help to show that it's not as" " 376 complicated as most non-coders think. Writing code can be a" " 377 complicated process because it has to work but reading code is" " 378 altogether different and you don't need to know how to write code to" " 379 be able to read code. No more than you need to be able to write a book" " 380 to read a book or paint a painting to read a painting. This what we" " 381 need to make known.\"\" | tr a-x b-z" " 382 echo \"My current argument concerning the display of code (as opposed to " " 383 the process/outcome) is that the fact that the code contains" " 384 information that is directly relative to a conceptual reading of the" " 385 work, is inescapable. The problem, on the other hand, is that people" " 386 who don't read code, seem to have a general aversion to being put in" " 387 that position (where they must acknowledge the code). This is" " 388 something we need to help potential audiences to overcome. Pointing" " 389 out little things here and there will help to show that it's not as" " 390 complicated as most non-coders think. Writing code can be a" " 391 complicated process because it has to work but reading code is" " 392 altogether different and you don't need to know how to write code to" " 393 be able to read code. No more than you need to be able to write a book" " 394 to read a book or paint a painting to read a painting. This what we" " 395 need to make known.\" | tr a-x b-z" " 396 Downloads/re_store_present " " 397 clear" " 398 Downloads/re_store_present " " 399 echo Pall | tr a-x b-z" " 400 Downloads/re_store_present " " 401 echo best | tr a-x b-z" " 402 echo best r| tr a-x b-z" " 403 Downloads/re_store_present " " 404 cat Downloads/re_store_present | echo" " 405 echo < cat Downloads/re_store_present " " 406 cat Downloads/re_store_present " " 407 Downloads/re_store_present " " 408 cd Downloads/" " 409 ./re_store_present " " 410 sleep 0" " 411 sleep 0.09" " 412 ./re_store_present " " 413 mv re_store_present2 .." " 414 cd ~" " 415 ls re_store_present2 " " 416 ls re_store_present2 -lh" " 417 chmod +x re_store_present2 " " 418 ./re_store_present2 " " 419 nano re_store_present2 " " 420 ./re_store_present2 " " 421 clear" " 422 ./re_store_present2 " " 423 clear" " 424 ./re_store_present2 " " 425 cat re_store_present2 | wc -l" " 426 ./re_store_present2 " " 427 head -n 500 re_store_present2 " " 428 head -n 500 re_store_present2 | tail -n 1" " 429 head -n 00 re_store_present2 | tail -n 1" " 430 head -n 1 re_store_present2 | tail -n 1" " 431 head -n 12 re_store_present2 | tail -n 1" " 432 head -n 5" " 433 head -n 5 re_store_present2 " " 434 ./re_store_present2 " " 435 wc -l re_store_present2 " " 436 ./re_store_present2 " " 437 ./re_store_present2 " " 438 test 3=3" " 439 ./re_store_present2 " " 440 clear" " 441 ./re_store_present2 " " 442 clear" " 443 ./re_store_present2 " " 444 clear" " 445 ./re_store_present2 " " 446 clear" " 447 ./re_store_present2 " " 448 clear" " 449 man head" " 450 ./re_store_present2 " " 451 clear" " 452 ./re_store_present2 " " 453 clear" " 454 ./re_store_present2 " " 455 dict abet" " 456 dict abetted" " 457 ./re_store_present3" " 458 chmod +x re_store_present3" " 459 ./re_store_present3" " 460 nano ./re_store_present3" " 461 ./re_store_present3" " 462 ./re_store_present2" " 463 mv Downloads/re_store_present2 ." " 464 chmod +x re_store_present2" " 465 ./re_store_present2" " 466 nano ./re_store_present2" " 467 ./re_store_present2" " 468 ./re_store_present3" " 469 days=(mon tue wed thur fri sat sun)" " 470 echo \$days" " 471 echo \${days[@]}" " 472 echo \${days[*]}" " 473 echo \${#days[*]}" " 474 echo \${#days[@]}" " 475 for ((i=0; i<\${#days[@]}; i++)) { echo \${days[\$i]} ; }" " 476 dict successive" " 477 days[8]=\"jamesday\"" " 478 for ((i=0; i<\${#days[@]}; i++)) { echo \${days[\$i]} ; }" " 479 {days[8]}=\"jamesday\"" " 480 days[8]=\"jamesday\"" " 481 for ((i=0; i<\${#days[@]}; i++)) { echo \${days[\$i]} ; }" " 482 days[3]=\"jamesday\"" " 483 for ((i=0; i<\${#days[@]}; i++)) { echo \${days[\$i]} ; }" " 484 arr[1]=\"Hello\"" " 485 echo {\$arr[1]}" " 486 echo \${arr[1]}" " 487 arr[12]=\"Hello there\"" " 488 echo \${arr[12]}" " 489 ./re_store_present4" " 490 chmod +x re_store_present4" " 491 ./re_store_present4" " 492 clear" " 493 ./re_store_present4" " 494 cat -n re_store_present4" " 495 man head" " 496 ./re_store_present4" " 497 clear" " 498 ./re_store_present4" " 499 cat -n re_store_present4" " 500 ./re_store_present4") hist_line_count=${#hist_arr[@]} hist_first_line=-$v_scroll_lines hist_line=0 src_line_count=`cat $0 | wc -l` src_first_line=-$v_scroll_lines src_line=1 # display a message to user because this next part is # very slow... echo "Initialising..." # first, read the contents of this file line by line, # formatting each line as we go, and then placing it # into successive array indexs of the array $src_arr. while [ "$src_line" -lt "$src_line_count" ] do # get line $src_line from file: ln=`head -n $src_line $0 | tail -n 1` # add spaces before line number as necessary: if [ "$src_line" -lt "10" ]; then spc=" " elif [ "$src_line" -lt "100" ]; then spc=" " elif [ "$src_line" -lt "1000" ]; then spc=" " else spc=" " fi # add spaces, line number, and the line together: fln="${spc}${src_line} ${ln}" # remove characters in excess of width... src_arr[$src_line]=${fln:0:width} let src_line=src_line+1 done # remove initialising message... clear # decode messages. (by enclosing a command in backticks # it allows to capture the output of that command(s) into # a variable, in this case, called msg1 & msg2). # also, add a few more extraneous characters to messages # to give people a chance to read the beginning of them # without waiting for them to scroll back round... msg1=`echo "- - - - - - - -" $secret_msg1 | tr b-z a-x` msg2=`echo "- - - - - - - -" $secret_msg2 | tr b-z a-x` # note: the original (encoded) messages have line breaks # within them, these are removed by echo-ing them without # enclosing quotes, while within the scroll-loop (below) # the messages are echo-ed within enclosing quotes (which # preserves any spaces at beginning of output... # length in characters of messages: len1=${#msg1}; len2=${#msg2}; src_ticker=0; hist_ticker=0; while true do echo -e $reset_cursor # -e enables processing of escape sequences. echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). echo #display v-scrolling history from creating this script... display_count=$v_scroll_lines line=hist_first_line; while [ "$display_count" -gt "0" ] do let line=line+1 if [ "$line" -lt "1" ]; then echo elif [ "$line" -lt "$hist_line_count" ]; then echo -n "${hist_arr[$line]:0:width}" echo -e $erase_line else echo fi let display_count=display_count-1; done let hist_ticker=hist_ticker+1 if [ "$hist_ticker" -eq "2" ] then hist_ticker=0 let hist_first_line=hist_first_line+1 if [ "$hist_first_line" -eq "$hist_line_count" ] then hist_first_line=-$v_scroll_lines fi fi # now display the second message scrolling along horizontal echo echo "${msg2:0:width}" first=${msg2:0:2} rest=${msg2:2:len2-2} msg2=${rest}${first} # v-scroll this script source echo display_count=$v_scroll_lines line=src_first_line; while [ "$display_count" -gt "0" ] do let line=line+1 if [ "$line" -lt "1" ]; then echo elif [ "$line" -lt "$src_line_count" ]; then echo -n "${src_arr[$line]}" echo -e $erase_line else echo fi let display_count=display_count-1; done let src_ticker=src_ticker+1 if [ "$src_ticker" -eq "1" ] then src_ticker=0 let src_first_line=src_first_line+1 if [ "$src_first_line" -eq "$src_line_count" ] then src_first_line=-$v_scroll_lines fi fi sleep 0.1 # a pause to prevent scrolling too fast. done #end of file