Hello All,
PC OS Specs:
OpenSuSE 11.4 - 2.6.37.6-0.5-desktop --> Gnome
So I wrote these 3 simple scripts to do a job that is kind of annoying to do everytime I need it, so I am trying to automate it somewhat.
The script is made up of 3 files:
1. Shell Script - calls 2 expect files
2. Expect Script - executes mount cmd
3. Expect Script - executes umount cmd
The script works just fine if I run it in terminal (but that is kind of pointless bc it would be the same as having to open a terminal and executing the cmds directly).
So what I am trying to do is, I added a "Custom Application Launcher" to the taskbar that simply executes what ever file you specify, but when I click that icon it only displays the "xmessage" cmd and does not execute anything else...
Here are my scripts:
callMount.sh
Code:
#!/bin/sh
#DISPLAY=":0.0"
mount | grep -i sdb
GREP_RETCODE=$?
#echo "Grep-ReturnCode = "$GREP_RETCODE
if (("$GREP_RETCODE" == "0"))
then
./umount.exp
xmessage -center "SSD has been UNMOUNTED"
else
./mount.exp
xmessage -center "SSD has been MOUNTED"
fi
mount.exp
Code:
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
#set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout 1
#spawn /bin/sudo mount /dev/sdb1 /mnt/SSD
spawn $env(SHELL)
expect_after {
timeout {
exit 2
}
}
expect {
timeout {exit 2}
"userName*" {send "sudo mount /dev/sdb1 /mnt/SSD\r"}
}
expect {
timeout {exit 2}
"*password:" {send "myPassword\r"}
}
expect {
timeout {exit 0}
# "userName*" {send "exit\r"}
}
umount.exp
Code:
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
#set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout 1
#spawn /bin/sudo mount /dev/sdb1 /mnt/SSD
spawn $env(SHELL)
expect_after {
timeout {
exit 2
}
}
expect {
timeout {exit 2}
"userName*" {send "sudo umount /mnt/SSD\r"}
}
expect {
timeout {exit 2}
"*password:" {send "myPassword\r"}
}
expect {
timeout {exit 0}
}
So I know each command works on their own, because I have run each one from the command-line but when I click the icon for the "Custom Application Launcher" the only thing that happens is that it displays the "xmessage" cmd.
Any help would be greatly appreciated...
Thanks,
Matt