input variable like POST in PHP possibly?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting input variable like POST in PHP possibly?
# 1  
Old 07-04-2007
input variable like POST in PHP possibly?

I have a very large database and once in awhile the database auto loading scripts that update the database for the daily updates fails and I have to go in and manually fix it but when that happens I usually have to start from scratch on sundays I have access to a weekly database rebuild. Then I have to apply each day thereafter to complete the process.

I have the weekly taken care of in a script that downloads the weekly update, unzips it, and uses some .sql scripts to load the information into the database. But I have 6 other scripts that have to be run one at a time for each of the days that may follow the weekly rebuild. What I am wanting to do is combine all 7 scripts into a single file say manual_rebuild.sh and then call that script with something like this:

./manual_rebuild.sh wed

The script would pick up that "wed" variable and it would download the weekly update unpack, load, delete the weekly .zip file then do monday, tuesday, and wednesday the same way. But I dont know how to define a variable like that from outside the script. If anyone has any clues please fill me in. Possibly a code example? Thank you...
# 2  
Old 07-04-2007
Quote:
Originally Posted by chadrt
But I dont know how to define a variable like that from outside the script.
To explicitly set a variable that will last for the scope of the script in sh, bash or ksh, do

Code:
WEEKDAY=wed ./manual_rebuild.sh

or to get a command line argument into a variable do this at start of script

Code:
#!/bin/sh
WEEKDAY=$1
...

# 3  
Old 07-05-2007
Excellent, thank you very much the second one is what I was looking for! Just out of curiosity is it possible to have the script promt for the days to run like

Would you like to rebuild from last weeks major update? [yes/no]:

Would you like to add monday's update to the database? [yes/no]:

and it would carry out that set of instructions if you choose yes and if you choose no it would end the script.

That may be a little beyond the scope of a shell script but I am new at all this so the fact that I have written a script to do anything is amazing in itself. These scripts are my first attempts at any shell scripting. Thank again for the help...
# 4  
Old 07-05-2007
Decided to do a little research on my own to try and figure this out I found a few things and this is what I have so far.

Code:
#!/bin/bash

echo -n "Would you like to rebuild DB from latest weekly?:"
read weekly
echo ""
echo You said $weekly
if [ $weekly = yes ] ; then
echo "This works!";

I get a small error about "unexpected end of file" but I think I am on the right track so far. I need figure out how I would do an ELSE. and then I can just put all my scripts in to one and use multiple sets of the above code, modified to work of course. Thanks for the assistance...
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How would I construct a (possibly simple) IF statement?

Hi all, I thought this would be simple, but I've been having a lot of trouble trying to write this IF statement, if I may ask for help pls: In BASH, how would I construct the if statement: Should ONLY be true if USEROPTscript=="yes"]] AND $mode=="INSTALL" /or/ $mode=="CHANGE" ]]... (3 Replies)
Discussion started by: jmccoughlin
3 Replies

2. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

3. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

4. HP-UX

Cdrom device possibly missing?

Hello, I am following the HPUX 11.31 install/update guide and I am trying to install "Update-UX" from the installation media. I put the CD into the drive, and I am trying to mount the device. The instructions state:Find the DVD-ROM device file name: ioscan -C disk -f -n -k | more A typical... (5 Replies)
Discussion started by: bstring
5 Replies

5. UNIX for Dummies Questions & Answers

$PATH error (possibly)

Upon opening Terminal I get the following message: -bash: /usr/bin/manpath: No such file or directory -bash: /usr/bin/perl: No such file or directory -bash: grep: command not found -bash: grep: command not found -bash: grep: command not found -bash: grep: command not found I searched... (9 Replies)
Discussion started by: SartreSmartre
9 Replies

6. Shell Programming and Scripting

Combining find, grep and possibly ls?!

Hi - can someone please help me combine find, grep and possibly ls into something workable: i.e. How can I list all the files that contain the word "pet" in all directories under the current directory that are called "animal", bar those anywhere under directories called "archive"? I suspect... (6 Replies)
Discussion started by: cs03dmj
6 Replies

7. Solaris

Why in.mpathd errors - performance possibly?

Hello all, Run a search but see no previous queries. Trying to get to the bottom of why a server running Solaris 9 reports the following every other day: lonpcbcfp1:Jun 20 16:33:20 lonpcbcfp1 in.mpathd: missed sending 17 probes cur_time 1478014085 snxt_time 1478015026 snxt_basetime 1478014018... (0 Replies)
Discussion started by: bookiebarton
0 Replies

8. Shell Programming and Scripting

stupid question possibly

how would I search through subdirectories under the current directory and delete all files in certain directories. in ThisDirectory.... want to go into foundMe directory which there are several in other subdirectories and delete all files in foundMe ? thank you... (1 Reply)
Discussion started by: MrJaunty
1 Replies
Login or Register to Ask a Question