Conky doesn't display bash-script variables (array)

I've been playing around with Conky and a bash script of mine. Unfortunately Conky displays only static text and not the array-variables in my script.
In my script:
...some code here...
echo "Static text: ${Variable[1]}"
In my conkyrc:
...some code here...
${exec ~/Test/test.sh}
The result is: "Static text: ". When running the script from the command line everything is fine. I've also tried with exec, execi, execp, texeci to no avail. Any ideas?
Edit: I had to be more specific.
Last edited by chilebiker (2009-10-06 03:30:20)

Try echo -n "Static text: ${Variable[1]}"

Similar Messages

  • [Solved] - Bash scripting - variable question.

    Hi!
    I have a little problem, I want to get data from a variable, but the variable-name that I want to
    get the data from is constructed by another variable.
    Let me explain with a little non-working example:
    test1="data1"
    test2="data2"
    test3="data3"
    for i in {1..3};do
    echo value=$[test$i];done
    I want to get the output of this code to be:
    value=data1
    value=data2
    value=data3
    and I cannot use arrays in the script I'm working on. I know how to do this in other languages
    but cannot figure it out how to do it in bash.
    Please help!
    Last edited by JSHN (2009-10-06 19:55:15)

    you need the eval command to finish how you started:
    eval echo value=\$test$i
    Otherwise, use bash arrays:
    test=('data1' 'data2' 'data3')
    for i in $(seq 0 2);do # zero-based...
    echo value=${test[$i]}
    done
    ninja-edit to remove the comma's in the array
    Last edited by klixon (2009-10-06 19:27:03)

  • [SOLVED] FFMPEG appears to be trashing bash script variables

    Hi,
    I have a directory containg MP4 files which were downloaded via youtube-dl upon which I want to extract audio using FFMPEG.
    I am using the usual find/while/read/do/done loop to process each file individually. The files were downloaded using Youtube-dl (invoked with --restrict-filenames) so the youtube video ID is recorded within the filename which can then be used to obtain the video title (ie to tag the audio with once extracted, ie ID3).
    Without FFMPEG the loop works as expected as can be seen when using echo, but as soon as I introduce FFMPEG into the loop, no such file or directory errors are reported because the filenames passed to FFMPEG are nonsense and appear to have been trashed, for instance, characters are stripped from the start or end of the filename.
    find . -name '*.mp4' | while read FILE
    do
    FNAME=${FILE%.mp4}
    FID=${FNAME: -11}
    FTITLE=${FNAME%-$FID}
    TITLE=$(youtube-dl --get-title $FID)
    # MP3="${FNAME}.mp3"
    AAC="${FNAME}.aac"
    ffmpeg -i $FILE -vn -acodec copy $AAC
    done
    Frequently green text like so reams down the terminal:
    stream #1:
    keyframe=1
    duration=0.023
    dts=355.033 pts=355.033
    size=252
    Swiftly followed by:
    00000000 21 0a 4f ff ff e0 3f fe a2 c6 b1 41 31 a0 88 41 !.O...?....A1..A
    00000010 28 3e 00 03 d2 15 25 4a 92 17 40 0b e4 f5 4c e5 (>....%[email protected].
    00000020 af 56 45 aa 31 0c eb 87 45 ac 26 54 8a ed c9 b4 .VE.1...E.&T....
    00000030 94 98 ca a8 03 34 aa bf 04 51 38 12 c9 43 80 62 .....4...Q8..C.b
    00000040 5b 16 94 99 20 18 9e cd 55 d0 6c 15 38 13 ce cc [... ...U.l.8...
    00000050 d4 2e 80 3b 10 e9 07 70 bc 23 8c 8c 84 96 8a 38 ...;...p.#.....8
    00000060 29 63 8d 87 75 5e 66 dc fa de 7f 4e 70 b2 44 09 )c..u^f....Np.D.
    00000070 39 c7 30 50 78 2b 6a b0 48 90 ba c4 14 c4 41 5c 9.0Px+j.H.....A\
    00000080 b6 3c 64 38 4d 92 3a b6 d1 01 d3 99 86 d5 54 23 .<d8M.:.......T#
    00000090 2a c4 13 49 61 50 b7 d0 3c 1e 2b 4b 90 c4 32 ae *..IaP..<.+K..2.
    000000a0 bc 6b 57 a6 de df 19 53 8e 38 66 d1 c4 fc a4 d5 .kW....S.8f.....
    000000b0 f9 6f a9 2d 20 6c eb 29 1e 1a ef 96 a6 84 82 63 .o.- l.).......c
    000000c0 0a cc 75 82 14 b4 08 09 fa 11 b8 0d e7 11 80 84 ..u.............
    000000d0 20 31 18 00 05 2a 54 af 46 ac 08 79 b9 a8 11 70 1...*T.F..y...p
    000000e0 f5 c0 2f 88 4b 27 7c a4 fd f9 f1 e4 77 53 c5 4a ../.K'|.....wS.J
    000000f0 d7 74 d1 02 80 46 40 08 16 a1 e7 .t...F@....
    It doesn't matter if the filenames originate from find or redirected from the contents of a text file. Anyone have any suggestions for workarounds?
    Last edited by jwm-art (2014-05-27 21:39:39)

    Self contained example:
    #!/bin/bash
    while read URL
    do
    echo -n "Downloading video from ${URL}... "
    youtube-dl --restrict-filenames "${URL}" --quiet
    if test $? -eq 0; then
    echo "Ok"
    else
    echo "FAIL"
    echo "Aborting..."
    exit
    fi
    done <<YT_URLS
    https://www.youtube.com/watch?v=XqdYnxv01yM
    https://www.youtube.com/watch?v=lX_o5t2YoUE
    https://www.youtube.com/watch?v=V9sI6VEDE5M
    YT_URLS
    find . -name '*.mp4' | while read -r FILE
    do
    echo "-----------------------------------------"
    echo -n "Converting ${FILE} to MP3... "
    MP3="${FILE%.mp4}.mp3"
    echo "${MP3}"
    ffmpeg -loglevel warning -y -i "${FILE}" "${MP3}"
    if test $? -eq 0; then
    echo "Ok"
    else
    echo "FAIL"
    echo "Abortingm..."
    exit
    fi
    echo
    done
    Here's the output on my system:
    $ ../ffmpeg_test
    Downloading video from https://www.youtube.com/watch?v=XqdYnxv01yM... Ok
    Downloading video from https://www.youtube.com/watch?v=lX_o5t2YoUE... Ok
    Downloading video from https://www.youtube.com/watch?v=V9sI6VEDE5M... Ok
    Converting ./Rabbit_City_White_Lable_-_Beyond_Control-lX_o5t2YoUE.mp4 to MP3... ./Rabbit_City_White_Lable_-_Beyond_Control-lX_o5t2YoUE.mp3
    Enter command: <target>|all <time>|-1 <command>[ <argument>]
    Parse error, at least 3 arguments were expected, only 1 given in string 'osmo_Dibs_-_Xultation-V9sI6VEDE5M.mp4'
    debug=1
    debug=2 1984kB time=00:02:06.95 bitrate= 128.0kbits/s
    error parsing debug value
    debug=0
    [output stream 0:0 @ 0xd90b60] EOF on sink link output stream 0:0:default.
    No more output streams to write to, finishing.
    [libmp3lame @ 0xc71de0] Trying to remove 815 more samples than there are in the queue
    size= 6971kB time=00:07:26.12 bitrate= 128.0kbits/s
    video:0kB audio:6971kB subtitle:0 data:0 global headers:0kB muxing overhead 0.004483%
    19212 frames successfully decoded, 0 decoding errors
    [AVIOContext @ 0xd9ff60] Statistics: 2 seeks, 17081 writeouts
    [AVIOContext @ 0xc77200] Statistics: 7082450 bytes read, 176 seeks
    Ok
    The first MP4 file found is converted, but alongside strange unexplained output, and then it just stops. In the first iteration of the second loop how does FFMPEG get hold of the second filename (incomplete, missing first character)? What is the "Enter command" all about? Its all very weird.
    Last edited by jwm-art (2014-05-27 20:17:57)

  • Can't get conky-cli and bash scripts to both display in dwm statusbar!

    I'm trying to configure my dwm status bar to display some simple information using conky-cli and bash scripts. At first I tried just letting conky run the bash scripts (for network and volume state), but this increased my cpu usage by about 5%, which is significant considering I normally have 1-3% usage when idle. Also, I wanted to keep conky because it makes the display of certain information easy, such as cpu & RAM usage.
    The problem is I'm having trouble getting both to display side by side. Here are the relevant parts of my .xinitrc:
    network(){
    iwconfig wlan0 2>&1 | grep -q no\ wireless\ extensions\. && {
    echo wired
    exit 0
    essid=`iwconfig wlan0 | awk -F '"' '/ESSID/ {print $2}'`
    stngth=`iwconfig wlan0 | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1`
    bars=`expr $stngth / 10`
    case $bars in
    0) bar='[-------]' ;;
    1) bar='[#------]' ;;
    2) bar='[##-----]' ;;
    3) bar='[###----]' ;;
    4) bar='[####---]' ;;
    5) bar='[#####--]' ;;
    6) bar='[######-]' ;;
    7) bar='[#######]' ;;
    *) bar='[--!!!--]' ;;
    esac
    echo $essid$bar
    exit 0
    volume(){
    vol=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "MM" } else { print $2 }}' | head -n 1)
    echo Vol: $vol%
    exit 0
    conky | while true; read line; do xsetroot -name "`$line` `volume` `network` `date '+%a %m-%d-%Y %I:%M%p'`"; done &
    exec dwm
    (let me know if it would help to post any other files)
    For some reason when I run this I only get the network/volume scripts and date running, updating every second (I think). The conky line just doesn't show up. I don't know what could be wrong, since I didn't see any error messages.
    An even better solution would be to just have shell scripts to display CPU and MEM usage. I have a dual-core cpu, cpu0 and cpu1. I'd like to see both percentages if possible, or at least a percentage that is an accurate average of the two or something. In conky-cli I have something that shows:
    cpu0/1: xx% xx%
    Also, seeing RAM usage would help a lot. In conky it shows:
    mem: xx% (xxxMB)
    These are the ways I would like to have bash scripts show them, if possible, but I have zero skill in bash programming. I made this an option in case it's easier/cleaner/less resource hungry than a conky solution. Personally, if they're about the same in these aspects, I would prefer something with conky and the shell scripts because conky is so extensible, yet it's only flaw is executing scripts with minimal resource usage.
    Help?

    Thanks. I was thinking of using load average to save a few characters, but I didn't quite understand the numbers. I'll try that once I get to my Linux box, but could you please explain or post a link to something that explains load average (what's low, high, normal, etc.)?
    EDIT: I found a website that explains loadavg. I now have my dwm status bar displaying it perfectly (yay!). Now I just need to add a few more things like battery status, etc. and I might be done. I'll probably post here if I have more questions, though.
    Thanks for your help!
    Last edited by Allamgir (2009-07-18 14:41:11)

  • [solved]Need help with a bash script for MOC conky artwork.

    I need some help with a bash script for displaying artwork from MOC.
    Music folders have a file called 'front.jpg' in them, so I need to pull the current directory from MOCP and then display the 'front.jpg' file in conky.
    mocp -Q %file
    gives me the current file playing, but I need the directory (perhaps some way to use only everything after the last  '/'?)
    A point in the right direction would be appreciated.
    thanks, d
    Last edited by dgz (2013-08-29 21:24:28)

    Xyne wrote:
    You should also quote the variables and output in double quotes to make the code robust, e.g.
    filename="$(mocp -Q %file)"
    dirname="${filename%/*}"
    cp "$dirname"/front.jpg ~/backup/art.jpg
    Without the quotes, whitespace will break the code. Even if you don't expect whitespace in any of the paths, it's still good coding practice to include the quotes imo.
    thanks for the tip.
    here it is, anyhow:
    #!/bin/bash
    filename=$(mocp -Q %file)
    dirname=${filename%/*}
    cp ${dirname}/front.jpg ~/backup/art.jpg
    then in conky:
    $alignr${execi 30 ~/bin/artc}${image ~/backup/art.jpg -s 100x100 -p -3,60}
    thanks for the help.
    Last edited by dgz (2013-08-29 21:26:32)

  • Bash script doesn't work (Also, help me condense it)...

    I am trying to make myself a bash script which combines files together based off of a config file. It is automating combining the audio book tracks I ripped of my CDs into chapters for easier reference. My first problem is that even though I used ', cat still thinks that everything is a separate file. My second problem is that it is way too long, any way I can have it automatically go up 1 chapter until a specified number (ie, until the value of the CHAPTERS variable)? Thanks to those who help.
    chapcomb.sh
    #!/bin/bash
    # * ChapterCombine *
    # * By smartboyathome *
    # * A script which was made to combine *
    # * chapters from ripped audio books *
    # * together, but can be edited to *
    # * combine just about anything. *
    # * The config file is located in your *
    # * home directory, under the name *
    # * '.chapcomb.config'. If you do not *
    # * have this file, create it. *
    # * Otherwise this script will not *
    # * run, as it won't have the proper *
    # * variables. *
    # * This can be changed by changing *
    # * the CONFIG variable below. *
    # * Licensed under: *
    # * SmartLicense version 1.0 *
    VERSION=0.1
    usage() {
    echo "Chapter Combine v$VERSION"
    echo "A configuration file must be made in order to use this script. Configuration files are located at $CONFIG. This can be changed by adding CONFIG='blah' before this command, or by changing the script directly. See the sample file for how it should look."
    while [ "$#" -ne "0" ]; do
    case $# in
    --help)
    usage
    exit 0
    -h)
    usage
    exit 0
    esac
    done
    # The config file stuff.
    if [ -z "$CONFIG" ]; then
    CONFIG="$HOME/.chapcomb.config"
    fi
    . $CONFIG
    cd "$BOOKDIR"
    combine() {
    # Checks if file exists, and if so, deletes it.
    if [ -a $NAME ]; then
    rm $NAME
    fi
    # Combines files
    cat $FILES >> $NAME
    # Checks to make sure that the chapter combined ok.
    if [ -s "$NAME" ]; then
    echo "File $NAME is ok."
    else
    echo "File $NAME had an error and didn't combine. Please fix config file and rerun this script."
    exit 0
    fi
    chapter01
    combine
    chapter02
    combine
    chapter03
    combine
    chapter04
    combine
    chapter05
    combine
    chapter06
    combine
    chapter07
    combine
    chapter08
    combine
    chapter09
    combine
    chapter10
    combine
    chapter11
    combine
    chapter12
    combine
    chapter13
    combine
    chapter14
    combine
    chapter15
    combine
    chapter16
    combine
    chapter17
    combine
    chapter18
    combine
    chapter19
    combine
    chapter20
    combine
    chapter21
    combine
    chapter22
    combine
    chapter23
    combine
    chapter24
    combine
    chapter25
    combine
    chapter26
    combine
    chapter27
    combine
    chapter28
    combine
    chapter29
    combine
    .chapcomb.config
    # Config file for ChapterCombine
    # DO NOT DELETE, OR CHAPTERCOMBINE WILL NOT FUNCTION!
    # Book's Directory
    BOOKDIR='/media/Home/aabbott/Star Wars Fate of the Jedi Outcast'
    # Each chapter's settings.
    chapter01() {
    # FILES='Outcast\ Disc\ 1/01\ Track\ 1.mp3 Outcast\ Disc\ 1/02\ Track\ 2.mp3 Outcast\ Disc\ 1/03\ Track\ 3.mp3 Outcast\ Disc\ 1/04\ Track\ 4.mp3'
    FILES="'Outcast Disc 1'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4'}.mp3"
    NAME='Chapter01.mp3'
    chapter02() {
    # FILES='Outcast\ Disc\ 1/05\ Track\ 5.mp3 Outcast\ Disc\ 1/06\ Track\ 6.mp3 Outcast\ Disc\ 1/07\ Track\ 7.mp3 Outcast\ Disc\ 1/08\ Track\ 8.mp3 Outcast\ Disc\ 1/09\ Track\ 9.mp3 Outcast\ Disc\ 1/10\ Track\ 10.mp3 Outcast\ Disc\ 1/11\ Track\ 11.mp3'
    FILES="'Outcast Disc 1'/{'05 Track 5','06 Track 6','07 Track 7','08 Track 8','09 Track 9','10 Track 10','11 Track 11'}.mp3"
    NAME='Chapter02.mp3'
    chapter03() {
    # FILES='Outcast\ Disc\ 1/12\ Track\ 12.mp3 Outcast\ Disc\ 1/13\ Track\ 13.mp3 Outcast\ Disc\ 1/14\ Track\ 14.mp3 Outcast\ Disc\ 1/15\ Track\ 15.mp3 Outcast\ Disc\ 1/16\ Track\ 16.mp3'
    FILES="'Outcast Disc 1'/{'12 Track 12','13 Track 13','14 Track 14','15 Track 15','16 Track 16'}.mp3"
    NAME='Chapter03.mp3'
    chapter04() {
    # FILES='Outcast\ Disc\ 2/01\ Track\ 1.mp3 Outcast\ Disc\ 2/02\ Track\ 2.mp3 Outcast\ Disc\ 2/03\ Track\ 3.mp3 Outcast\ Disc\ 2/04\ Track\ 4.mp3'
    FILES="'Outcast Disc 2'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4'}.mp3"
    NAME='Chapter04.mp3'
    chapter05() {
    FILES="'Outcast Disc 2'/{'05 Track 5','06 Track 6','07 Track 7','08 Track 8'}.mp3"
    NAME='Chapter05.mp3'
    chapter06() {
    FILES="'Outcast Disc 2'/{'09 Track 9','10 Track 10','11 Track 11','12 Track 12','13 Track 13'}.mp3"
    NAME='Chapter06.mp3'
    # This one needs some special parameters as the chapter is split between two Discs.
    chapter07() {
    FILES="{'Outcast Disc 2'/{'14 Track 4','15 Track 15','16 Track 16','17 Track 17'}.mp3,'Outcast Disc 3'/{'01 Track 1','02 Track 2','03 Track 3'}}.mp3"
    NAME='Chapter07.mp3'
    chapter08() {
    FILES="'Outcast Disc 3'/{'04 Track 4','05 Track 5','06 Track 6','07 Track 7','08 Track 8'}.mp3"
    NAME='Chapter08.mp3'
    chapter09() {
    FILES="'Outcast Disc 3'/{'09 Track 9','10 Track 10','11 Track 11'}.mp3"
    NAME='Chapter09.mp3'
    chapter10() {
    FILES="'Outcast Disc 3'/{'12 Track 12','13 Track 13','14 Track 14','15 Track 15'}.mp3"
    NAME='Chapter10.mp3'
    chapter11() {
    FILES="'Outcast Disc 4'/{'01 Track 1','02 Track 2','03 Track 3'}.mp3"
    NAME='Chapter11.mp3'
    chapter12() {
    FILES="'Outcast Disc 4'/{'04 Track 4','05 Track 5','06 Track 6','07 Track 7','08 Track 8'}.mp3"
    NAME='Chapter12.mp3'
    chapter13() {
    FILES="'Outcast Disc 4'/{'09 Track 9','10 Track 10','11 Track 11'}.mp3"
    NAME='Chapter13.mp3'
    chapter14() {
    FILES="'Outcast Disc 4'/{'12 Track 12','13 Track 13','14 Track 14'}.mp3"
    NAME='Chapter14.mp3'
    chapter15() {
    FILES="{'Outcast Disc 4'/'15 Track 15','Outcast Disc 5'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4','05 Track 5'}}.mp3"
    NAME='Chapter15.mp3'
    chapter16() {
    FILES="'Outcast Disc 5'/{'06 Track 6','07 Track 7','08 Track 8','09 Track 9'}.mp3"
    NAME='Chapter16.mp3'
    chapter17() {
    FILES="'Outcast Disc 5'/{'10 Track 10','11 Track 11','12 Track 12','13 Track 13'}.mp3"
    NAME='Chapter17.mp3'
    chapter18() {
    FILES="{'Outcast Disc 5'/'15 Track 15','Outcast Disc 6'/{'01 Track 1','02 Track 2'}}.mp3"
    NAME='Chapter18.mp3'
    chapter19() {
    FILES="'Outcast Disc 6'/{'03 Track 3','04 Track 4','05 Track 5','06 Track 6','07 Track 7','08 Track 8'}.mp3"
    NAME='Chapter19.mp3'
    chapter20() {
    FILES="'Outcast Disc 6'/{'09 Track 9','10 Track 10','11 Track 11','12 Track 12','13 Track 13','14 Track 14'}.mp3"
    NAME='Chapter20.mp3'
    chapter21() {
    FILES="'Outcast Disc 6'/{'15 Track 15','16 Track 16','17 Track 17','18 Track 18','19 Track 19'}.mp3"
    NAME='Chapter21.mp3'
    chapter22() {
    FILES="'Outcast Disc 7'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4'}.mp3"
    NAME='Chapter22.mp3'
    chapter23() {
    FILES="'Outcast Disc 7'/{'05 Track 5','06 Track 6','07 Track 7','08 Track 8'}.mp3"
    NAME='Chapter23.mp3'
    chapter24() {
    FILES="'Outcast Disc 7'/{'09 Track 9','10 Track 10','11 Track 11','12 Track 12','13 Track 13'}.mp3"
    NAME='Chapter24.mp3'
    chapter25() {
    FILES="{'Outcast Disc 7'/{'14 Track 14','15 Track 15','16 Track 16','17 Track 17'},'Outcast Disk 8'/'01 Track 1'}.mp3"
    NAME='Chapter25.mp3'
    chapter26() {
    FILES="'Outcast Disc 8'/{'02 Track 2','03 Track 3','04 Track 4','05 Track 5'}.mp3"
    NAME='Chapter26.mp3'
    chapter27() {
    FILES="'Outcast Disc 8'/{'06 Track 6','07 Track 7','08 Track 8','09 Track 9'}.mp3"
    NAME='Chapter27.mp3'
    chapter28() {
    FILES="'Outcast Disc 8'/{'10 Track 10','11 Track 11','12 Track 12','13 Track 13'}.mp3"
    NAME='Chapter28.mp3'
    chapter29() {
    FILES="'Outcast Disc 8'/{'14 Track 14','15 Track 15','16 Track 16'}.mp3"
    NAME='Chapter29.mp3'

    kumyco wrote:
    for FILES=test/{a,b,c} you may want to do something like
    FILES=$(echo test/{a,b,c})
    That's a good one. And eval would work with simple examples, but once you have spaces and such in filenames it won't work I think.
    If you are going to do this often, then there are too many things that can go wrong with a script that tries to automatically generate the filenames. Even 01* can go wrong.
    So if you do have the filenames all in the .conf, then you can replace FILES= with cat and NAME= with >
    The actual script doesn't add that much, except checking if it exists (just use > instead of >>) and if it isn't empty (not really necessary) (why did you put a license on that? is that even legal?)
    So just use the .conf file as the main script.
    Turn this:
    BOOKDIR='/media/Home/aabbott/Star Wars Fate of the Jedi Outcast'
    chapter01() {
    FILES="'Outcast Disc 1'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4'}.mp3"
    NAME='Chapter01.mp3'
    chapter02() {
    FILES="'Outcast Disc 1'/{'05 Track 5','06 Track 6','07 Track 7','08 Track 8','09 Track 9','10 Track 10','11 Track 11'}.mp3"
    NAME='Chapter02.mp3'
    into this:
    cd '/media/Home/aabbott/Star Wars Fate of the Jedi Outcast'
    cat 'Outcast Disc 1'/{'01 Track 1','02 Track 2','03 Track 3','04 Track 4'}.mp3 > 'Chapter01.mp3'
    cat 'Outcast Disc 1'/{'05 Track 5','06 Track 6','07 Track 7','08 Track 8','09 Track 9','10 Track 10','11 Track 11'}.mp3 > 'Chapter02.mp3'
    Right?
    Why would you build anything around that?
    If you are sure the filenames are all the same, you can use *
    cat *\ 1/*\ {1..4}.mp3 > Chapter01.mp3
    cat *\ 100/*\ {70..99}.mp3 > Chapter99.mp3

  • Conky with a bash script

    I am trying to change the color of my CPU temp text in conky to green, yellow or red based on the CPU temp.  I am getting this in my conky:
    Temperature:  color green33
    Here is my conky line:
    ${voffset 1}${goto 40}Temperature: ${font Droid Sans:style=Bold:size=8}${execpi 120 sensors | grep Core0 | paste -s | cut -c15-18 | xargs ~/.conky/colorize.sh}${hwmon 0 temp 1}°C${color}${font}${alignr}
    Here is my bash script:
    #!/bin/bash
    # colorize.sh
    COOL=65
    WARM=80
    if [[ $1 < $COOL ]];
    then
    echo "color green"
    elif [[ $1 > $WARM ]];
    then
    echo "color red"
    else
    echo "color yellow"
    fi
    exit 0
    Any help would be greatly appreciated.
    Thanks

    Using exec(p)(i) makes your conky run heavier, so, why wouldn't you use the built-in conky variables to achieve the same...
    I'm using: (before "TEXT")
    template2 ${color2}${if_match ${hwmon \1 temp \2}>75}${color orange}${if_match ${hwmon \1 temp \2}>90}${color red}${endif}${endif}${hwmon \1 temp \2}${color1}
    and i call them like: (after "TEXT")
    Temp ${template2 0 1}/${template2 1 1}/${template2 2 2}/${template2 2 4}
    Of course you need to find out what numbers you need to pass to hwmon...

  • RichEditableText doesn't display bindable variable "mavar" where autoComplete

    Hello,
    RichEditableText doesn't display bindable variable "mavar" where autoComplete and textFlow link
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx" 
            minWidth="955" 
            minHeight="600"
            applicationComplete="comp()">
            <fx:Script>        
                    <![CDATA[
                            [Bindable]
                            public var mavar : String;
                            public function comp():void {
                                    mavar = 'toto';
                    ]]>
            </fx:Script>
            <!-- Launch your application by right clicking within this class and select Debug As > FDT SWF Application -->
            <fx:Declarations>
                    <!-- Place non-visual elements (e.g., services, value objects) here -->
            </fx:Declarations>
            <s:RichEditableText id="richEdTxt" editable="false" selectable="false">
                    <s:textFlow>
                            <s:TextFlow>
                                    <s:p>{mavar}<s:a href="http://www.monsite.com/">www.monsite.com</s:a></s:p>
                            </s:TextFlow>
                    </s:textFlow>
            </s:RichEditableText>
    </s:Application>

    Hi,
          try this
    <s:RichEditableText id="richEdTxt" editable="false" selectable="false">
            <s:textFlow>
                <s:TextFlow id="txtFlow">
                    <s:p><s:span>{mavar}</s:span><s:a href="http://www.monsite.com/">www.monsite.com</s:a></s:p>
                </s:TextFlow>
            </s:textFlow>
        </s:RichEditableText>
    thanks,
    Jayagopal.

  • How to send 2 variable value from bash script into java.class

    #!/bin/bash
      a=10
      b=20
       echo $a $b | java addition
    donehi there,
    currently i have a simple java coding ( a + b ). and i m trying to connect with bash script but this bash script coudln't Enter 2nd value (b=20) while i running for it. may i know how do i can Enter 2 value into it?
    output from terminal
    [seng@localhost java_class]$ bash addition.sh
    =======================================================================
    simulation 1
    Num_a       = 10
    Num_b       = 20
    Enter your Num_a : 10
    Enter your Num_b : Exception in thread "main" java.lang.NumberFormatException
       at java.lang.Integer.parseInt(java.lang.String, int, boolean) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Integer.parseInt(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at filter_god.GOD(java.util.List, java.util.List, java.lang.String, java.lang.String, int) (Unknown Source)
       at filter_god.main(java.lang.String[]) (Unknown Source)
       at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
       at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    =======================================================================

    That code will send both numbers on a single line in standard input to the java process. So if the process reads standard input, it will get a single line that has this in it: "10 20".
    I'm guessing you're sending that whole line to Integer.parseInt. But a valid number doesn't have a space in the middle.
    You should split up the line using String.split. Or use a StringTokenizer. Or a regular expression. Or you can use a java.util.Scanner. Or a java.io.StreamTokenizer. Or maybe some other stuff that has slipped my mind at the moment.

  • Bash Scripting with Conky -- How to implement?

    Hey Folks, my first post here and I'm looking for a bit of help. I've created a bash script to work with conky in which its purpose is to change the color of the battery bar depending on current voltage.
    Here's the bash script:
    #!/bin/bash
    # Change Conky battery color depending on charge
    chrg=`cat /proc/acpi/battery/BAT1/state | grep "remaining capacity" |
    awk '{print $3 }'`
    echo $chrg
    if [ $chrg -lt "3499" ]; then
    ${color red}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    elif [ "$chrg" -lt "5100"]; then
    ${color orange}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    else ${color green}${battery_percent BAT1}% ${battery_bar 4 BAT1}
    fi
    Essentially what it is supposed to do is grab and store the "remaining capacity" and if its lower than a certain point it changes color. What I'm having trouble with is actually implementing the colors into conky. Right now all it is doing is printing the charge as you can see. Any help would be appreciated. Thanks!

    I had this issue, took me three days to solve. Using if_match, put all your if_matches in a line, with each option having its color of choice, then put the bar, or % at the end.  You will need to make sure it is in sequential order so the color will not overlap the color you want for the state in the if_match. I know this is an old thread, I will edit my post when I get on my netbook with the code.
    I found this thread on a google search for bash and conky usages.
    [edit] here was my solution for the if_match using the battery.
    ${if_match ${battery_percent BAT1} <= 49}${color0}${endif}${if_match ${battery_percent BAT1} <= 20}${color9}${endif}${if_match ${battery_percent BAT1} >= 50}${color4}${endif}${battery BAT1} ${alignr}${battery_bar 6,160 BAT1}
    I have my colors set yellow for 49% and below, red 20% and lower, and last green for 50% and higher. Essentially this will pick yellow for under 49% and the if_match for red under 20%, the red will override the yellow, this is why order is important.
    Remember this is all in one line, now there are cleaner ways of setting this up using lua. That is something I am still working on.
    Last edited by mrknify (2014-03-05 17:09:59)

  • JDev903 debugger doesn't display local variable when debugging into JDK src

    Hi,
    I found that JDev903 debugger doesn't display local variables in the "smart data" and "data" panels when debugging into the JDK src. For most of the time, it only shows "this" object.
    Is this right? How do I setup JDev903 to display local variables in debugger?
    thanks,
    Richard

    Hi Fred,
    Did you forget to put resultFormat=&quot;e4x&quot;?

  • OpenScript script variables - can store multiple values or an array?

    Hello,
    I'm helping with a proof-of-concept for driving the Primavera P6 web services using OpenScript, and I'm having a bit of trouble using the script variables. One of the web services can return anywhere from 0 to many objects, and I was trying to save those object IDs into a script variable. The built-in "substitute variable" seemed to work great, but the variable only contains the last result, not all of them. Here's the line that's saving the value:
    http.solve("objIdsToDelete", "<ObjectId>(.+?)</ObjectId>", "", true, Source.Html, 0, EncodeOptions.None);
    Even if there are, for example, 5 <ObjectId> in the response, the variable only has the last result... Any suggestions on how I can tweak this (different regular expression?) to either store an array or a comma-separated list of all the values?
    Thanks!
    -Troy Newton

    Hi Troy,
    Sorry about my last answer. It wasn't too specific. So if you want to collect the whole array instead of a specific value (referenced by the index) you would change e.g.
    http.solve("formsload.loginsubmit_1",
                                  "FORM_SUBMIT_BUTTON':'(.+?)'", "", false, Source.Html,
                                  1, EncodeOptions.None);
    which would give you the second value from the array (remember that arrays are indexed from 0) to
    http.solve("formsload.loginsubmit_1",
                                  "FORM_SUBMIT_BUTTON':'(.+?)'", "", false, Source.Html,
                                  null, EncodeOptions.None);
    Notice the null, this will return an array to the coolection. You can then reference these by:
              String myStrings[]=getVariables().getAll("formsload.loginsubmit_1");
                        info("Number of elements in array is :" + myStrings.length);
                        for (int i=0;i<myStrings.length;i++)
                             info("Element Number " + i + ":" + myStrings [ i ] );
    This will result in an output like:
    0 Passed Comments: Number of elements in array is 2
    0 Passed Comments: Element Number 0: Submit Button
    0 Passed Comments: Element Number 1: Cancel
    I hope this helps.....
    Regards
    Wayne.
    Edited by: byrne_wayne on Nov 26, 2010 1:40 PM
    Edited by: byrne_wayne on Nov 26, 2010 4:42 PM

  • [SOLVED] problem with spaces and ls command in bash script

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble:
    HOMEDIR="/home/panos/Web Site"
    for file in $(find "$HOMEDIR" -type f)
    do
    if [ "$(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)")" -gt 30 ];
    then echo -e "File $file is $(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)") old\r" >> /home/panos/scripts/temp;
    fi
    done
    The dateDiff() function is defined earlier and the script works fine when I change the HOMEDIR variable to a path where there are no spaces in directory and file names. I have isolated the problem to the ls command, so a simpler code sample that also doesn't work correctly with path names with spaces is this:
    #!/bin/bash
    HOMEDIR="/home/panos/test dir"
    for file in $(find "$HOMEDIR" -type f)
    do
    ls -lh "$file"
    done
    TIA
    Last edited by panosk (2009-11-08 21:55:31)

    oops, brain fart. *flushes with embarrassment*
    -- Edit --
    BTW, for this kind of thing, I usually do something like:
    find "$HOMEDIR" -type f | while read file ; do something with "$file" ; done
    Or put those in an array:
    IFS=$'\n' ; files=($(find "$HOMEDIR" -type f)) ; unset IFS
    for file in "${files[@]}" ; do something with "$file" ; done
    The later method is useful when elements of "${files[@]}" will be used multiple times across the script.
    Last edited by lolilolicon (2009-11-09 08:13:07)

  • Sending email using bash script

    Hello:
    I am working on writing a bash script to notify one or more users by email of certain events. Run from the Terminal command line, and having the script "echo" text of (what would be) a form letter with in-line variable expansion (i.e., ${VARIABLE}), all seems to work as anticipated. Eventually, I want cron to launch this shell script, and send an email to an "on-subnet" user (I have postfix enabled on my Mac, and there are multiple local user accounts).
    I found some stuff on the web about sending mail from bash scripts, and so I made a small little test script, that reads like this:
    #!/bin/bash
    VARIABLE[1]="The 12,345 quick brown foxes "
    VARIABLE[2]="jumped over the 67,890 lazy dogs."
    mail -s "a test email" jv << EOF
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EOF
    echo "script completed"
    It worked... almost... It sent a local email to my postfix mail account that read like this:
    This is a test:
    The 12,345 quick brown foxes
    jumped over the 67,890 lazy dogs.
    This is the last line of the test message.
    EOF
    echo "script completed"
    So, I have two questions. First, the easy one (I hope):
    How do I delimit the end of the text, that I want to be the message body of the email, from portions of the script that follow said email text?
    Next question is a little more involved. You know how, in Mail.app, if you go to Mail Preferences>Accounts>Account Information, you can put multiple email addresses, comma-delimited, in the "Email Address" field? So, if a person entered "[email protected], [email protected], [email protected]" in this field, then, even though (s)he may be at home, and using their home ISP's mail server, (s)he could send an email apparently from either their home, work, or school email address. Of course, the mail headers clearly would show it came from and through their home machine and home ISP, but it would be displayed in the recipient's Mail client viewer as having come from one of [email protected], [email protected], or [email protected].
    I'd like to do something similar here, whereby the email (that is being sent to one or more local users' postfix account on my computer) would apparently be sent from "watchdog@localhost" rather than from "jv@localhost" like it seems to do by default. Whatever account the script is run from (or presumbably, whose cron tab is launching the script) is what the "From" address is set to.
    I'd rather not create an additional mail account, because I am using Mac OS X built-in accounts for the postfix mailboxes (I don't want to have to maintain a plaintext username:password file in postfix, and I don't want to create an additional user account on the computer).
    So, is there a way to specify an alternate "From" username when invoking the mail -s ${SUBJECT} ${RECIPIENT} command in a bash script? Or is there a different, alternate mail command that will let me do so? (please include a description of syntax and how I'd package the above message text for the alternate method).
    Thanks in advance, all!

    Hi j.v.,
    The > after EOF is just a typo (or may be added by the Discussion ?) and you must delete it; other > are prompts from the interactive shell. Andy's post shows an interactive use of shell, not a shell script (note the shell prompt % in front of the commands). A typical use of here document may look like
    command <<ENDOFDATA
    ENDOFDATA
    There must be no spaces before and after ENDOFDATA. The word ENDOFDATA can be EOF or any other string which is guaranteed not to appear in the text (the .... in the example above).
    You can modify the From: header by using sendmail command (postfix has it as a compatibility interface):
    /usr/sbin/sendmail -t <<EndOfMessage
    Subject: test mail
    To: jv
    From: watchdog
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EndOfMessage
    There must be a blank line between the headers and the mail body.
    I assume that you send these mails only to users on your local Mac. Please do not send mails to remote users by using the sendmail command unless you know what you are doing completely.
    PowerMac G4   Mac OS X (10.4.5)  

  • What do you think of my Bash Script? What about the error checking?

    Well what do you think of this Bash script
    It works
    I gave it some problems (i.e. unpluged the ethernet, messed up the URL's, uninstaled some programs...) to see if would report errors and stop or just keep going... But it did
    I just kind of thought up a way to do some error checking with the commands that I know.....
    What is a better way to do error checking?
    What do you think I should add/Do to this script?
    #!/bin/bash
    # Shell script to make a USB Tumb Drive for Flashing BIOS on a Lenovo Ideapad Y510.
    # This script needs to be owned and run as ROOT with the "sudo command"
    # i.e. sudo usbbiosflasher
    # If you have anyideas send me a PM on ubuntufourms.org my user name is HunterThomson
    # Name/Rename this script usbbiosflasher and save it to the ~/home directory.
    # Then run the command- chown root:root usbbiosflasher
    # Then run the command- chmod 755 usbbiosflasher
    # Then copy the script to the directory /usr/bin.
    # Run this comand to do that- sudo cp ~/usbbiosflasher /usr/bin
    # You also must have the program "mbr" installed
    # You can install the mbr program by running this comand in the shell on Ubuntu
    # sudo apt-get install mbr
    # In Arch Linux you have to get it from Aur
    # First you will need to know a few things...
    # You will also need to know the Mount Point i.e. /media/disk and the /dev path i.e. /dev/sdb1.
    # You can find these by using the df -T comand.
    # Run df -T in the shell. Then plug in the USB Thumb Drive and run the df -T comand agin.
    # The new listing is the USB Thumb Dirve.
    # Also check to make sure the File System tipe is vFAT or FAT16 or FAT32.
    # If it is not use gparted to format it to FAT32.
    # I am farly certen that all USB Thumb drives come formated with FAT file system out of the BOX.
    # You may want to fromat it anyway just to make sure.
    echo "Interactive Shell Script to Make a USB Thumb Drive \for Flashing BIOS On a Lenovo Ideapad Y510"
    echo ""
    echo "You will need to have the program mbr installed"
    echo "If you are on Ubuntu Linux you can retreve it form the repositories"
    echo "If you are on Arch Linux you will need to get it from the Aur repository"
    echo "Open anuther shell and \do that now..."
    echo ""
    verify="n"
    while [ "$verify" != y ]
    do
    printf "Do you have mbr installed... yes or no?"
    read AN1
    echo ""
    printf "You answered... $AN1 I have installed mbr. Is this correct... y or n?"
    read verify
    done
    echo ""
    if [ "$AN1" == "no" ]
    then
    echo "Install mbr now. Then run this script agin"
    exit
    else
    echo "contunuing script"
    fi
    echo ""
    # The next comand will make a directory to put needed files into. Note this file and everything init will be owned by root.
    mkdir ~/usbbiosfiles && check1="yes"
    if [ "$check1" = "yes" ]
    then
    echo "Made directory usbbiosfiles... OK"
    else
    echo "Could not \make directory usbbiosfiles"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    exit
    fi
    # The next two comands will get the FreeDOS file and the .ROM file.
    cd ~/usbbiosfiles && checka="yes"
    if [ "$checka" = "yes" ]
    then
    echo "Changing to the usbbiosfiles directory... OK"
    else
    echo "Could not Change to the usbbiosfiles directory"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    wget "http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz" && check2="yes"
    if [ "$check2" = "yes" ]
    then
    echo "Download of FreeDOS... OK"
    else
    echo "Could not Download FreeDOS"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    wget "http://ubuntuforums.org/attachment.php?attachmentid=78460&d=1216648756" && check3="yes"
    if [ "$check3" = "yes" ]
    then
    echo "Download of the BIOS.ROM \file... OK"
    else
    echo "Could not Downlad the BIOS.ROM \file"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    # The next comand will name the .ROM file to the right name.
    mv ~/usbbiosfiles/attachment.php?attachmentid=78460\&d=1216648756 ~/usbbiosfiles/06CN29WW.bios.update.tar.bz2 && check4="yes"
    if [ "$check4" = "yes" ]
    then
    echo "Renameing of the BIOS.ROM \file... OK"
    else
    echo "Could not rename the BIOS.ROM \file"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    echo ""
    # The next two comands set the variables. DEVX for the path i.e. /dev/xxx and MOUNTX for the mount point i.e. /media/xxx
    verify="n"
    while [ "$verify" != y ]
    do
    echo "You will need to know the Mount Point and the dev Path. You will also need to \make sure the File System \type is vFAT, FAT16 or FAT32."
    echo ""
    echo "With the USB Thumb Drive unpluged, Open another shell and run the comand df -T Then plug \in the USB Thumb Drive and run the comand df -T one \more time. The new device listed is the USB Thumb Drive. Note the Mount Point and The dev Path and the File system Type i.e. vFAT... If the File System \type is not vFAT, FAT16 or FAT32 you will need to fromat it with gparted. You may want to format the USB Thumb Drive anyway just to \make sure. In any \case delete all files and directorys on the USB drive before you go any ferther with this program."
    echo ""
    printf "Enter the dev path the USB Thumb Drive is at?"
    read DEVX
    echo ""
    echo "Are you sure $DEVX is the dev path of the USB Thumb Drive... y or n?"
    read verify
    done
    echo ""
    verify="n"
    while [ "$verify" != y ]
    do
    printf "What is the Mount Point of the USB Thumb Drive?"
    read MOUNTX
    echo ""
    echo "Are you sure $MOUNTX is the Mount Point of the USB Drive... y or n?"
    read verify
    done
    echo ""
    install-mbr --enable A1 --partition 1 --force --timeout 0 $DEVX && check5="yes"
    if [ "$check5" = "yes" ]
    then
    echo "Installing MBR on USB Thumb Dirve... OK"
    else
    echo "Could not install MBR on USB Thumb Drive"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    tar xjf ~/usbbiosfiles/*.tar.bz2 && check7="yes"
    if [ "$check7" = "yes" ]
    then
    echo "Unpacking BIOS.ROM file... OK"
    else
    echo "Could not unpack BIOS.ROM file"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    gunzip ~/usbbiosfiles/FDOEM.144.gz && check8="yes"
    if [ "$check8" = "yes" ]
    then
    echo "Unpacking FreeDOS files... OK"
    else
    echo "Could not unpack FreeDOS files"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    mkdir ~/usbbiosfiles/fdoem144 && check9="yes"
    if [ "$check9" = "yes" ]
    then
    echo "Made directory fdoem144 in direcoty usbbiosfiles... OK"
    echo ""
    echo "Going to \sleep \for 5secs"
    else
    echo "Could not make directory fdoem144 in usbbiosfiles directory"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    modprobe loop && sleep 5 && check0="yes"
    if [ "$check0" = "yes" ]
    then
    echo "Modprobeing loop... OK"
    else
    echo "Could not \modprobe loop"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    mount -o loop ~/usbbiosfiles/FDOEM.144 ~/usbbiosfiles/fdoem144 && check10="yes"
    if [ "$check10" = "yes" ]
    then
    echo "Mounting FreeDOS on the fdoem144 directory... OK"
    else
    echo "Could not \mount FreeDOS on the fdoem144 directory"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    cp ~/usbbiosfiles/fdoem144/* $MOUNTX && check11="yes"
    if [ "$check11" = "yes" ]
    then
    echo "Copying FreeDOS files to $MOUNTX... OK"
    else
    echo "Could not copy FreeDOS files to $MOUNTX"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    cp ~/usbbiosfiles/*.ROM $MOUNTX && check12="yes"
    if [ "$check12" = "yes" ]
    then
    echo "Copying BIOS.ROM files to $MOUNTX... OK"
    else
    echo "Could not copy BIOS.ROM files to $MOUNTX"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    sync && check13="yes"
    if [ "$check13" = "yes" ]
    then
    echo "Runing the syncing command... OK"
    else
    echo "Could not run the syncing command"
    echo "look above \for \info"
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this scrip agin"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    rm -r ~/usbbiosfiles
    exit
    fi
    umount ~/usbbiosfiles/fdoem144 && check14="yes"
    if [ "$check14" = "yes" ]
    then
    echo "Unmounting of FreeDOS... OK"
    else
    echo "Could not unmount FreeDOS"
    echo "Look above for errors or problems reported and fix the problem"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this script agin"
    rm -r ~/usbbiosfiles
    exit
    fi
    verify="n"
    while [ "$verify" != y ]
    do
    printf "Do you see any errors... yes or no?"
    read AN2
    echo ""
    printf "You answered... $AN2 to errors. Is this correct... y or n?"
    read verify
    done
    echo ""
    if [ "$AN2" == "yes" ]
    then
    echo "User Repoted... Error"
    echo "Look above for errors or problems reported and fix the problem"
    echo ""
    echo "removeing directory usbbiosfiles..."
    echo ""
    echo "Reformat the USB Stick to FAT32 with gparted"
    echo "Fix the problem and run this script agin"
    rm -r ~/usbbiosfiles
    exit
    else
    echo "Success"
    echo "I did a lot of error checking too and didnt find anything"
    echo ""
    echo "Go get a pen and paper to write down these instructions"
    printf "Then hit the Enter to continue"
    read WAIT
    echo ""
    echo "Now leave the USB Thumb Drive pluged into your computer and Reboot. When the Lenovo Logo POST screen appears hit F2 to enter the CMOS setup utility. Go over to BOOT tab and go down to HardDrive \(Not Boot Order) \then \select the USB Thumb Drive as the 1st hard drve. Then F10 and yes to save changes. Your compter will reboot agin. Then when the Lenovo Logo POST Screen appers on reboot hit F4 to enter the BIOS FLASHING program. The USB Thumb Drive will be seen as the C drive \in the list on the Left, Select it. Then \select the .ROM \file \in the list on the Right and start the BIOS FLASH. \(NOTE Your hart may stop beating... This is normal) Pray to any God you know of and your computer should restart just like normal. Hit F2 and the BIOS will now stay it is 06CN29WW. You will need to \set the boot order to the way you like it and other things \if you need to because they have been changed to the default."
    fi
    echo ""
    echo "End of script"
    Last edited by hunterthomson (2008-08-10 11:17:47)

    Personally.....  (this is just how I would have written it - if it works, then it's good enough for me though )
    I would change this whole block:
    verify="n"
    while [ "$verify" != y ]
    do
    printf "Do you have mbr installed... yes or no?"
    read AN1
    echo ""
    printf "You answered... $AN1 I have installed mbr. Is this correct... y or n?"
    read verify
    done
    echo ""
    if [ "$AN1" == "no" ]
    then
    echo "Install mbr now. Then run this script agin"
    exit
    else
    echo "contunuing script"
    fi
    To this much shorter code:
    MBR='/usr/bin/install-mbr' # Or where ever you expect it to be
    if [ ! -x $MBR ] ; then
    echo "mbr doesn't appear to be installed."
    echo "If it is installed, check it's location, make sure it's executable and then make sure the MBR variable in this script is correct"
    exit 1
    fi
    I wouldn't have used the checkXX variables for each stage:
    mkdir ~/usbbiosfiles
    if [ $? != 0 ] ; then
    #failed
    echo "Could not \make directory usbbiosfiles"
    echo "look above \for \info"
    echo "Fix the problem and run this scrip agin"
    exit 1
    else
    echo "Made directory usbbiosfiles... OK"
    fi
    There is an issue with the way you do your verifications - the user can never get out unless they answer 'y' or hit CTRL+C. Something like this gives them options:
    verify="n"
    while [ "$verify" != "y" && "$verify" != "n" ]; do
    echo "You need to answer 'y'es or 'n'o"
    read verify
    echo $verify | tr "[:upper:]" "[:lower:]" # This converts the answer to lowercase so replies entered in upper case will still work
    done
    if [ $verify != 'y' ] ; then
    exit 1
    fi
    One last thing I try to do in scripts... Declare all your binaries as variables at the start of the program, then execute the binary program by using the variable. For example:
    # Binaries
    TAR='/bin/tar'
    CP='/bin/cp'
    CHMOD='/bin/chmod'
    # Execute tar and chmod the created file
    $TAR cvzf /tmp/tarfile.tar.gz /etc/*.conf
    $CHMOD 400 /etc/*.conf
    This way, it's easy to change the path in future without having to hunt through the script if the paths change, and it also ensures you're calling the programs using the full paths to make sure you're not executing some strange variant or alias that someone has setup. If I use `chmod` 30 times in a script, and the path changes in the future or on a different system (`chmod` is a bad example cause it's highly unlikely to change, but you know what I mean), then all you need to do is update the variable at the start of the script, and it all works again without having to script-hunt and change it 30 times.

Maybe you are looking for