views:

42

answers:

4

how i can pass a file directory (path) as parameter to 1. batch file in windows operating system 2. bash file in unix oprating system

+1  A: 

With windows batch file, you use %1 (%2, %3 etc). With Bash, you use $1 ($2,$3...).

ghostdog74
+1  A: 
Batch files can only handle parameters %0 to %9

%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.

For Batch check @ http://www.robvanderwoude.com/parameters.php

For shell script check @ http://docsrv.sco.com:507/en/OSUserG/_Passing_to_shell_script.html

Panther24
+1  A: 

1) To a Windows batch file:

script.bat C:\some\path

To access the path in the script use %1:

echo %1

2) To a bash shell script:

script.sh /some/path

To access the path in the script use $1:

echo $1
dogbane
A: 

In bash, you use $1 to get the first parameter. You're saying it has to be a path to directory, so you may want to try the following:

test -d $1 && echo "Directory exists"
ecik