FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Linux - simple shell script how to turn ECHO off ?





turbosquid
I'm still a Linux noob, but i like what i see so far, obviously learning any new OS takes time so heres a quick and hopefully simple to answer question.

I am writing a simple batch file (i believe they are known as shell scripts in linux?)
please excuse my ignorance Smile

The script is simply an automated way of installing Flash Player 9 on my linux box the script itself works fine but i wanted to know how to turn ECHO OFF, for example in a Windowz .bat file you would use '@ECHO OFF' but how do i accomplish the same in Linux??

Here is my very basic script:-

Code:

# Flash PLayer 9 Install script
#
clear
echo "Hi $USER this is the simple Flash Player 9 Install script."
#
# Removing flashplugin nonfree
echo "Removing old Flash Plugins."
sudo apt-get remove flashplugin-nonfree
rm ~/.mozilla/plugins/*flash*
#
# Download Flash Player 9
echo "Downloading Flash-PLayer-9 from http://fpdownload.macromedia.com."
wget -c http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz
echo "Download Complete."
#
# Install Flash Player 9
echo "Installing Flash Player 9."
tar -xvzf install_flash_player_9_linux.tar.gz
sudo mv install_flash_player_9_linux/libflashplayer.so /usr/lib/firefox/plugins/
sudo mv install_flash_player_9_linux/flashplayer.xpt /usr/lib/firefox/plugins/
echo "Installed."
#
# Clean Up
echo "Cleaning up."
rm install_flash_player_9_linux.tar.gz
#rm -r install_flash_player_9_linux
echo "All Tasks Completed."
exit 0


Like i say it works but when you run the script i only want it to show the actual text that is echoed and not everything else.

Any help would be greatly appreciated

TurboSquid
MrBlueSky
Code:

set -v off


should work in most shells

But I wonder why it is showing the commands in the first place? How do you execute the script?
qscomputing
Assuming you are using bash, the commands are not echoed by default. But how are you executing the script?

First of all you need a shabang line to tell the computer which shell to use:
#!/bin/bash

Then you can chmod it executable:
chmod a+x script_file_name
(or use your filemanager's GUI controls to do the same)

Then you execute it like this:
./script_file_name

Unix shells typically don't echo commands as the script is executed. HTH.
turbosquid
I have had a bit more of a mess around with the script and now got it to do what i wanted it to Smile
I think i was trying to use the wrong method to prevent the script outputting stuff onto the screen. It turns out that "tar" "apt-get" "wget" were all outputting stuff i have since found out how to put them into quiet mode so now it's all good!

here is the revised code for anyone who maybe interested?

Code:
#!/bin/bash
#
# Flash Player 9 Install script
#
clear
set +v
echo "Flash Player 9 Installer."
echo ""
#
# Removing flashplugin non-free
echo "Checking for and removing old Flash Plugins."
sudo apt-get -qq remove flashplugin-nonfree
if [ -d /.mozilla/plugins/*flash* ]; then
echo "Old Plugins found and removed"
rm ~/.mozilla/plugins/*flash*
else
echo "No old Plugins found. Skipping."
fi
#
# Download Flash Player 9
echo ""
echo "Downloading Flash-Player-9 from http://fpdownload.macromedia.com."
wget -qc http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz
echo "Download Complete."
echo ""
#
# Install Flash Player 9
echo "Installing Flash Player 9."
tar -xzf install_flash_player_9_linux.tar.gz
sudo mv install_flash_player_9_linux/libflashplayer.so /usr/lib/firefox/plugins/
sudo mv install_flash_player_9_linux/flashplayer.xpt /usr/lib/firefox/plugins/
echo "Installed."
echo ""
#
# Clean Up
echo "Cleaning up."
rm install_flash_player_9_linux.tar.gz
rm -rf install_flash_player_9_linux
echo "Removed temporary files & folders"
echo ""
echo "All Tasks successfully completed."
echo ""
exit 0


Thanks again for everyones help.

TurboSquid
Related topics
Complete Tutorial LINKS for every language
[COMMUNITY PROJECT]Frihost Forum
How to enable the shell script on the hosting site ?
simple login script
Shell script to automate rlogin
I need a VERY simple php script
conf editor prog
Will pay 100 FRIH$ for simple Windows program...
using cron jobs and scp to automate backups
shell Script and PHP
vBulletin installation: Files upload, Database setup
Trun Autorun off for Flash Drives
mysql adding new user with shell
Learing Shell Script
Reply to topic    Frihost Forum Index -> Computers -> Operating Systems

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.