Sponsored Content
Full Discussion: Help with A script
Homework and Emergencies Homework & Coursework Questions Help with A script Post 302595020 by balajesuri on Wednesday 1st of February 2012 11:56:29 PM
Old 02-02-2012
Quote:
Originally Posted by Aldaron47
Code:
if ( test $# -eq 4)
echo "Enter 4 files"
read $1 $2 $3 $4
then
touch $2
touch $3
otuch $4
cp $1 $2
cp $1 $3
cp $1 $4
else echo " Need exactly four parameters, sorry. "
fi

1. The lines which I've coloured red are contradictory. $1, $2, $3.... are positional parameters. You can't read values into them that way.
2. Your requirement was to create directories, not files, right? touch is used to change a file's access and modification time. If file doesn't exist, it creates them.
3. Try the below script. Let us know if you have any questions.
4. Please use code tags.

Code:
$ cat test.sh
#! /bin/bash

echo "Enter 4 dir names (1st is source. Next 3 are target dirs): "
read a b c d

for x in $b $c $d
do
    if [ ! -d $x ]
    then
        mkdir $x
        cp -r ./$a/* ./$x/
    else
        cp -r ./$a/* ./$x/
    fi
done
$
$ ./test.sh
Enter 4 dir names (1st is source. Next 3 are target dirs):
test test1 test2 test3
$
$ ls -l
drw-r--r-- 3 root root   4096 Jan 24 06:27 test
drwxr-xr-x 3 root root   4096 Feb  2 04:55 test1
drwxr-xr-x 3 root root   4096 Feb  2 04:55 test2
drwxr-xr-x 3 root root   4096 Feb  2 04:55 test3

'test' was an already existing dir. test1, test2, test3 are newly created dirs, which contains all of the data contained in 'test'
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

5. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
EXECUTE(7)						  PostgreSQL 9.2.7 Documentation						EXECUTE(7)

NAME
EXECUTE - execute a prepared statement SYNOPSIS
EXECUTE name [ ( parameter [, ...] ) ] DESCRIPTION
EXECUTE is used to execute a previously prepared statement. Since prepared statements only exist for the duration of a session, the prepared statement must have been created by a PREPARE statement executed earlier in the current session. If the PREPARE statement that created the statement specified some parameters, a compatible set of parameters must be passed to the EXECUTE statement, or else an error is raised. Note that (unlike functions) prepared statements are not overloaded based on the type or number of their parameters; the name of a prepared statement must be unique within a database session. For more information on the creation and usage of prepared statements, see PREPARE(7). PARAMETERS
name The name of the prepared statement to execute. parameter The actual value of a parameter to the prepared statement. This must be an expression yielding a value that is compatible with the data type of this parameter, as was determined when the prepared statement was created. OUTPUTS
The command tag returned by EXECUTE is that of the prepared statement, and not EXECUTE. EXAMPLES
Examples are given in the EXAMPLES section of the PREPARE(7) documentation. COMPATIBILITY
The SQL standard includes an EXECUTE statement, but it is only for use in embedded SQL. This version of the EXECUTE statement also uses a somewhat different syntax. SEE ALSO
DEALLOCATE(7), PREPARE(7) PostgreSQL 9.2.7 2014-02-17 EXECUTE(7)
All times are GMT -4. The time now is 05:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy