Capturing Input Parameters on Shell Script

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Capturing Input Parameters on Shell Script
# 1  
Old 11-03-2009
Capturing Input Parameters on Shell Script

i have this basic line of code that doesn't work. i simply want to get the input parameter strings but when the script is run it appears that the first parameter is assigning the value to the second parameter.



echo "directory: $pdir\n"
echo "parameter 1: $p1\n"
echo "parameter 2: $p2\n"

$ sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv
directory: /export/home/ccalftdv/apps

parameter 1: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

parameter 2: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

$ sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv
directory: /export/home/ccalftdv/apps

parameter 1: /u02/app/ccalloc/dev/out/EATVDAILY02132008.txt

parameter 2: /u02/app/ccalloc/dev/out/EATVDAILY03292007.txt


eventhough on the code it does not directly assign any to the second parameter.

i need to get the strings for each parameter e.g.:
$ sh /u02/app/ccalloc/dev/out/*.txt /export/home/ccalftdv

parameter 1: /u02/app/ccalloc/dev/out/*.txt 

parameter 2: /export/home/ccalftdv

how do i do that? thanks.
# 2  
Old 11-03-2009

The shell is expanding /.../*.txt to all *.txt files and they become arguments to the script.

To stop that, you could use quotes around the argument that would otherwise be expanded:


sh "/u02/app/ccalloc/dev/out/*.txt" /export/home/ccalftdv

# 3  
Old 11-03-2009
thanks so much that works.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for capturing FTP logs

I have a script #!/bin/bash USER=ftpuser PASSWORD=P@ssw0rd ftp -inv $HOST <<EOF user $USER $PASSWORD cd /path/to/file mput *.html bye EOF the script executes sucessfully I need to capture the FTP logs to a logfile should contain FTP Login successful ... (1 Reply)
Discussion started by: rajeshas83
1 Replies

2. Shell Programming and Scripting

Capturing name of the user who is running a shell script

Hello All, I am writing a shell script which will run on build server where multiple users can login.These users can run this script at the same time. I want to capture the name of the user who ran the script for every instance.How can I do that ? Regards,... (1 Reply)
Discussion started by: anand.shah
1 Replies

3. Shell Programming and Scripting

Capturing script output and input to log

Hi Is there a way that I can capture a shell script (both output and input) to a log file where I can analyze it? Thanks (6 Replies)
Discussion started by: nimo
6 Replies

4. Shell Programming and Scripting

Help parsing job script input parameters

I have a job script that runs with input parms from the command line. -p parm1_parm2_parm3_parm4_file_1.dat The parms are separated by _ The last parm is a file name and can have an _ in the name. I currently use the following commands to extract the parms parm1=`eval echo... (3 Replies)
Discussion started by: jclanc8
3 Replies

5. Shell Programming and Scripting

Capturing log of a shell script

Hi, I have a script which does multiple tasks in sequence. When i execute the script, it runs and displays lot of messages for each of the steps on the console. Is there any way I can capture those messages and store it for audit purposes ? Best Regards, bornon2303 (2 Replies)
Discussion started by: bornon2303
2 Replies

6. UNIX for Dummies Questions & Answers

Problem with Input Parameters using Shell Script

i have this basic code that accepts for two input one for the source file and the other is for the target directory. basically it is a simple copy command. the problem is at the end of the execution the second parameter string was passed to first parameter and it displays a message like: cp:... (3 Replies)
Discussion started by: wtolentino
3 Replies

7. Shell Programming and Scripting

Capturing Sybase SP output in Shell Script

Greetings, I need to capture the output of a Sybase stored procedure, inside my shell script( k shell). Based on this output, I need to call another perl script, with input arguments as the result set of the procedure execution. I need to keep looping through and call the perl script, ... (2 Replies)
Discussion started by: rajpreetsidhu
2 Replies

8. Shell Programming and Scripting

DB2 stored procedure (with input parameters) from script

I have a db2 stored procedure on my database which require 3 parameters, I have the following db2 command in a sql script CONNECT TO SAMPLE; CALL BACKUP(INPUT_1, INPUT_2, INPUT3); Usually, I would just invoke this sql script from my shell script like below db2 -tf... (1 Reply)
Discussion started by: mpang_
1 Replies

9. Shell Programming and Scripting

Need help capturing pipe to a file in shell script

The command: echo "this is some text" | shellscript abc def ghi My problem: How to capture "this is some text" so that I can process it, I.e. capture to a file. What I'm attemting to do is process the text echo'd into a file after writing the parameters passed first. No problem... (6 Replies)
Discussion started by: heinz
6 Replies
Login or Register to Ask a Question