LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Puppy (https://www.linuxquestions.org/questions/puppy-71/)
-   -   Replaceable parameter (https://www.linuxquestions.org/questions/puppy-71/replaceable-parameter-4175527379/)

Fixit7 12-04-2014 09:02 PM

Replaceable parameter
 
I am trying to use a replaceable parameter so I can just type

search.sh Blank.sh for example.

I guess I am not using it correctly.

Code:

find / -name $1

jlinkels 12-06-2014 08:01 AM

If the contents of search.sh contains the find statement $1 reflects the first parameter in the search call.

But I must say the information you provide is minimal. You don't post t he contents of you script file. You don't tell why you assume you don't use it correctly.

If you want assistance you should show at least the effort to post correctly. If that is too much effort, why do you expect someone's else effort.

jlinkels

pan64 12-06-2014 11:06 AM

you need to try the command locate to find files on your host (instead of find)

Fixit7 12-06-2014 01:35 PM

Quote:

Originally Posted by jlinkels (Post 5280420)
If the contents of search.sh contains the find statement $1 reflects the first parameter in the search call.

But I must say the information you provide is minimal. You don't post t he contents of you script file. You don't tell why you assume you don't use it correctly.

If you want assistance you should show at least the effort to post correctly. If that is too much effort, why do you expect someone's else effort.

jlinkels

I feel that you are being critical.

I am seeking help.

Fixit7 12-07-2014 01:22 PM

#!/bin/bash
# Faster than P_Find
# Find files using a replaceble parameter
# ex. Find_File.sh Blank.sh
#
# Linux Puppy 5.9.3
# SiegeWorks 2014 A.P.K.
#
clear
find / -name $1

jlinkels 12-07-2014 04:20 PM

For me it works and the file is shown as searched for. Where does it not for you? How do you call the script?

jlinkels

Fixit7 12-07-2014 06:00 PM

I do not understand this statement.

Quote:

Where does it not for you?
How do you call the script?

I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.

astrogeek 12-07-2014 06:13 PM

I don't think anyone was being critical, but I agree that it is not at all clear what problem you are seeking help with.

Perhaps an example would help, if you could show us how you call the script and what the result is, and why you think it is not correct.

For example...

Code:

Find_File somefilename

No such file or directory


jlinkels 12-07-2014 07:23 PM

Quote:

Originally Posted by Fixit7 (Post 5281070)
I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.

Code:

jlinkels@donald-pc:/tmp$ ./find_file.sh saints_marching.wav
<snip>
find: `/home/lost+found': Permission denied
/home/jlinkels/saints_marching.wav
find: `/mnt/homeserv/data/music/lost+found': Permission denied
<snip>

Quote:

Originally Posted by Fixit7 (Post 5281070)
#!/bin/bash
# Faster than P_Find
# Find files using a replaceble parameter
# ex. Find_File.sh Blank.sh
#
# Linux Puppy 5.9.3
# SiegeWorks 2014 A.P.K.
#
clear
find / -name $1

I am amazed that you have named your file Find_File.sh and are able to call it with Find_File without the .sh extension.

jlinkels

SAbhi 12-08-2014 12:00 AM

Quote:

Originally Posted by Fixit7 (Post 5281070)
I do not understand this statement.



How do you call the script?

I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.


No not that :

Code:

[dracula on client ~] $ cat testaprog.sh
#!/bin/bash
[ ! $1 ] && {
echo -e "err!! no input given"; exit 1; } || echo -e "doing something with $1";
[dracula on client ~] $

[dracula on client ~] $ ./testaprog.sh
err!! no input given

[dracula on client ~] $ ./testaprog
-bash: ./testaprog: No such file or directory


Fixit7 12-08-2014 09:29 AM

Quote:

Originally Posted by jlinkels (Post 5281095)
Code:

jlinkels@donald-pc:/tmp$ ./find_file.sh saints_marching.wav
<snip>
find: `/home/lost+found': Permission denied
/home/jlinkels/saints_marching.wav
find: `/mnt/homeserv/data/music/lost+found': Permission denied
<snip>

I am amazed that you have named your file Find_File.sh and are able to call it with Find_File without the .sh extension.

jlinkels

It's simple. Add your script directory to the path in /etc/profile.

There are many sripts on your system which have no extension.

When the kernel sees !#/bin/bash/ then it knows that it is a script.

Fixit7 12-08-2014 09:33 AM

Astrogeek,

I posted that my script is working. Maybe it is the lang
uage difference ?

jlinkels 12-08-2014 11:10 AM

Quote:

Originally Posted by Fixit7 (Post 5281356)
It's simple. Add your script directory to the path in /etc/profile.
There are many sripts on your system which have no extension.
When the kernel sees !#/bin/bash/ then it knows that it is a script.

Executing a file called Find_File.sh by calling it without the .sh extension is something I have to see yet.

jlinkels

Fixit7 12-08-2014 12:01 PM

Would you like me to post my console output ? :-)

astrogeek 12-08-2014 12:57 PM

Quote:

Originally Posted by Fixit7 (Post 5281360)
Astrogeek,

I posted that my script is working. Maybe it is the lang
uage difference ?

Yes it must be language barrier.

So, if it is working, do you have a question or were you only sharing your script?

Quote:

Originally Posted by Fixit7 (Post 5281424)
Would you like me to post my console output ? :-)

Yes, that might help us all to understand what you are asking or telling us.


All times are GMT -5. The time now is 05:47 AM.