1752354 Members
6314 Online
108787 Solutions
New Discussion юеВ

Re: Script addition

 
SOLVED
Go to solution
Adam W.
Valued Contributor

Script addition

Guru's I have attached a script a few of you came up with. I have a question though, How would I add a "test" to this? I think I have the correct syntax down, it is

If [[ $# != 1 ]]
then
echo ├в Test mode - Command would be: chown / chmod├в $FILENAME
else
perform chown/chmod
fi


But I am having trouble incorporating it into the script. Can someone help me with where to add this in, or know of an easier way?
There are two types of people in the world, Marines and those who wish they were.
16 REPLIES 16
James R. Ferguson
Acclaimed Contributor

Re: Script addition

Hi Adam:

#!/usr/bin/sh
if [ $# -ne 1 ]; then
echo "ONE argument only, please"
else
echo "OK, I saw one argument"
fi

...

Regards!

...JRF...
Michael Mike Reaser
Valued Contributor

Re: Script addition

JRF, I'd take it one step further:

#!/usr/bin/sh
if [ $# -ne 1 ]; then
echo "ONE argument only, please"
exit 99
else
echo "OK, I saw one argument"
fi

...

If not using one and only one argument, get the heck out of Dodge. :-)
There's no place like 127.0.0.1

HP-Server-Literate since 1979
Adam W.
Valued Contributor

Re: Script addition

James, pardon my ignorance here, however it would look like the attached correct? But in your statement, the else statement would only have it echo out "OK, I saw one arg." i need the else to push the chmod/chown commands.
There are two types of people in the world, Marines and those who wish they were.
Adam W.
Valued Contributor

Re: Script addition

See this is why I love ITRC. Sometimes I don't know what I would do without the knowledge you guys have.
There are two types of people in the world, Marines and those who wish they were.
James R. Ferguson
Acclaimed Contributor

Re: Script addition

Hi (again) Adam:

...
echo "TEST MODE - command would be: 'chown somebody ${FILENAME}'"
...

Regards!

...JRF...
Adam W.
Valued Contributor

Re: Script addition

OK, I have attached it. Does it look correct?
There are two types of people in the world, Marines and those who wish they were.
James R. Ferguson
Acclaimed Contributor

Re: Script addition

Hi Adam:

Please attach a TEXT file.

...JRF...
Adam W.
Valued Contributor

Re: Script addition

What text file?
There are two types of people in the world, Marines and those who wish they were.
Adam W.
Valued Contributor

Re: Script addition

oh lol Sorry about that.
There are two types of people in the world, Marines and those who wish they were.