Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old October 8th, 2002, 02:42 AM
drtebi drtebi is offline
Gentoo User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: LA/Madrid/Berlin
Posts: 21 drtebi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Please help with simple shell script

Hello,
I cannot seem to get this script to work, I assume it has something to do with the redirection? Please help...


#!/bin/sh

# little script to connect
# to MySQL and restore a backup

# variables
MYSQL='/usr/local/bin/mysql';
USER='joe';

if [ "$1" = '' ]
then
echo 'usage: mysqlrestore <database> <mysqldump>';
elif [ "$2" = '' ]
then
echo 'usage: mysqlrestore <database> <mysqldump>';
elif [ ! -f $2 ]
then
echo 'error: '$2' not found';
else
DATABASE=$1
BACKUP=$2;
# create command
COMMAND="$MYSQL -u $USER -p $DATABASE < $BACKUP";
# execute command
$COMMAND;
fi

Reply With Quote
  #2  
Old October 8th, 2002, 12:29 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
probably you need to escape the "<" -> "\<" or use single quotes.

i use one of these ways, they both work:
Code:
# create command
COMMAND="$MYSQL -u $USER -p $DATABASE";
# execute command
$COMMAND  < $BACKUP;
# you could also use "cat $BACKUP|$COMMAND"
fi
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old October 8th, 2002, 06:22 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,632 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 12 m 33 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
PLEASE don't cross-post, it's rude.

Reply With Quote
  #4  
Old October 9th, 2002, 04:26 AM
drtebi drtebi is offline
Gentoo User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: LA/Madrid/Berlin
Posts: 21 drtebi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Vielen Dank M. Hirsch,
das hat direkt geklappt. Ich hatte mir doch schon gedacht dass es etwas mit dem < Zeichen zu tun hatte.

Übrigens: mein Gott sind die Leute hier empfindlich wenn man einmal einen post in zwei Foren macht, ist ja unglaublich. Ich verspreche ich mache es nie wieder...

Nochmals Danke, das war eine gute Hilfe!

DrTebi

Reply With Quote
  #5  
Old October 9th, 2002, 12:03 PM
Tuxie Tuxie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Inside the GNU/Hurd kernel
Posts: 492 Tuxie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m
Reputation Power: 7
First you cross-post then you post in another language,thats also very rude,most people can't understand german (not that its bothers me in any way,since I understand german and its my favorite language ).

Reply With Quote
  #6  
Old October 9th, 2002, 12:34 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
hey, drtebi, let everyone here take part in our conversation

and cross-posting is considered bad habit in any bbs and newsgroup that i visited. so please, just don´t. we are one community here... an international one.

have phun - linux is

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Please help with simple shell script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway