Random parameters passing in FTP script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Random parameters passing in FTP script
# 1  
Old 06-12-2006
Random parameters passing in FTP script

Hi

I have a question.

In the FTP script if we are passing all the required value like Hostname, username, password, Action(put or get), Filename, & mode(ascii or binary) through parameters then we have to pass these in the exact orders in which they are taken like if we defined Username=$2 then we have to pass this as the second parameter.

Now if the user is completely unaware of the parameters numbering & passes all the parameters randomly, is there a way to identify which value belongs to which parameters.

Thanks
Sourabh
TCS
# 2  
Old 06-12-2006
use options and getopts

Make your script accept options like Unix commands.

Code:
myftpscript.sh -h hostname -m mode -u user -p passwd -a action -U usage

Use getopts inside the script to assign the actual values. See this linkfor some pointers towards getopts.

Last edited by ranj@chn; 06-12-2006 at 12:11 PM.. Reason: typo
# 3  
Old 06-12-2006
Random parameters passing in FTP script

Hi

Seems a fanstastic solution, hey can u suggest some more alternative in which the user just pass only the values without any option as user still have to be aware of -h for hostname etc.

Really appreciate ur previous reply and will use that


Thanks
Sourabh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing command line parameters into script

Not a good post. (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

2. Shell Programming and Scripting

Shell Script passing parameters to sqlplus code

Hello All, I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible? Thanks (4 Replies)
Discussion started by: compprog11
4 Replies

3. Shell Programming and Scripting

passing parameters to the script

how can i make a script to run only when parameters are given, if parameters are not given it should through an error , saying "please enter a parameter" for ex: i want a find command to run only when the parameters are given (4 Replies)
Discussion started by: knip
4 Replies

4. Shell Programming and Scripting

Passing parameters to bash script function (or subroutine)

I've found a few posts regarding passing parameters to a function or subroutine, but for some reason when I try to run a command based on part with these parameters it's not working. If I have the function echo the parameters they show correctly so I believe they are being passed right but the... (2 Replies)
Discussion started by: withanh
2 Replies

5. Shell Programming and Scripting

passing parameters from a script to a datastage job

We have a requirement as follows. We have created a datastage job that will be doing the select operation from table (select query from a table). The datastage job is being invoked by a unix shell script(ksh). We are passing the "table name (STUD_DETAILS)" and a "where clause condition... (4 Replies)
Discussion started by: kmanivan82
4 Replies

6. Shell Programming and Scripting

specified path name is too long passing parameters to awk via shell script

Hello, I have this shell script that runs awk code by passing in parameters however now it doesn't work anymore with the parameters and I don't know why. It removes duplicates from an input file based on a part of the last field and a key column. It removes the record with the older datetime... (0 Replies)
Discussion started by: script_op2a
0 Replies

7. Shell Programming and Scripting

Shell Script Passing Parameters For Directory Listing

i have this basic piece of code that i am trying to debug to accept input parameter to be able to display a directory listing of files. cd /u02/app/eatv/dev/out CURDIR=`pwd` echo directory listing of $CURDIR echo if ; then ls -latr else ls -latr $1 fi basically if the script... (9 Replies)
Discussion started by: wtolentino
9 Replies

8. Shell Programming and Scripting

Passing parameters to Shell script for GREP command

I am using grep to capture date from a file . Since i need to use the shell script for different dates ,is it possible to pass the date parameter to the shell script the Script is as below grep -E "08 Aug 2008|2008-08-08"* somefile.txt>test.txt The above script file greps the... (1 Reply)
Discussion started by: sud.tech
1 Replies

9. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

10. UNIX for Dummies Questions & Answers

Passing parameters in script

I have 2 scripts: script1 and script2 Script1 passes 4 parameters to script2 as follows #script1 code ... ... script2 $var1 $var2 $var3 $var4 Script2 uses the export command to know to expect these values #script2 export $1 $2 $3 $4 code ... ... The problem that I am having is... (1 Reply)
Discussion started by: eliguy
1 Replies
Login or Register to Ask a Question