Can't get executable shell script to show output in Terminal

Forum rules
Before you post please read this

Can't get executable shell script to show output in Terminal

Postby dreamkatcha on Tue Feb 25, 2014 3:40 pm

Hi,

That just about says it all. I want it to, but it's not doing. I can't find anything in the preferences or properties menus of either Terminal or the shell script to allow me to do this so when I execute saved scripts I have to just cross my fingers and hope it's doing what it's supposed to, which is hardly ideal. Any ideas would be greatly appreciated please.
dreamkatcha
Level 1
Level 1
 
Posts: 21
Joined: Tue Jun 11, 2013 2:45 pm

Linux Mint is funded by ads and donations.
 

Re: Can't get executable shell script to show output in Term

Postby kurotsugi on Tue Feb 25, 2014 4:01 pm

Code: Select all
run-parts /path/to/script.sh > ~/kuroz.log
we can also include a log file or an echo flag to see whether if the script working or not. here's one of my script
Code: Select all
#!/system/bin/sh
# kuro flappy: flappy bird cheat script
# copyright@mycat (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : kaze.noichi17@gmail.com

LOG_FILE=/data/kuroz.log
DIR=/data/data/com.dotgears.flappybird/shared_prefs
if [ -e $LOG_FILE ]; then
   rm $LOG_FILE;
fi;

# the preface
echo "==========================
#  TWEAK AKURO-LOG FILE  #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor   : $( getprop ro.product.brand )
model    : $( getprop ro.product.model )
ROM      : $( getprop ro.build.display.id )

running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" >> $LOG_FILE;

# the real script start here
CHEAT=/sdcard/score
if [ -e $CHEAT ];
then
   mv $DIR/FlappyBird.xml $DIR/Flappy
   echo -e "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name=\u0022score\u0022 value=\u0022$(cat $CHEAT)\u0022 />
</map>" >> $DIR/FlappyBird.xml;
else
   mv $DIR/FlappyBird.xml $DIR/Flappy
   echo -e "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name=\u0022score\u0022 value=\u00225012\u0022 />
</map>" >> $DIR/FlappyBird.xml;
fi;

echo "SUCCESS!
your score have been updated" >> $LOG_FILE
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
--   have a nice day    --
      kurotsugi@xda
==========================" >> $LOG_FILE;

notice the "#!/system/bin/sh" that was a script for android but the trick should work on linux too. if you don't want to create log files you can use "echo" command as a notice
Code: Select all
#!/bin/bash
<whatever script you have here>
echo "success"
exit 0
kurotsugi
Level 5
Level 5
 
Posts: 890
Joined: Fri Jan 25, 2013 3:54 am

Re: Can't get executable shell script to show output in Term

Postby Pilosopong Tasyo on Tue Feb 25, 2014 9:42 pm

Moved from Xfce as this is a scripting question.

If you're running the scipt directly from the GUI, try this hack.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1103
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Can't get executable shell script to show output in Term

Postby dreamkatcha on Fri Feb 28, 2014 10:45 am

Thanks for the replies. I'll give those suggestions a go.

Yes, I'm running it from the GUI i.e. double-clicking the script's icon in Thunar running on Mint XFCE. In Mate there are options within the properties menu in the file manager that let you decide how you would like to run the script and what should happen to the Terminal when the script has executed.
dreamkatcha
Level 1
Level 1
 
Posts: 21
Joined: Tue Jun 11, 2013 2:45 pm


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 1 guest