The shell script doesn't get arguments, but parse them


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting The shell script doesn't get arguments, but parse them
# 8  
Old 07-25-2017
It would appear the author intended the script to be used in ways other than just how it's called from the cronjob. If you remove that from the script, can you guarantee it will not impact something else (e.g. where else is the script called from, and how is it called)?

Last edited by Scott; 07-25-2017 at 04:07 PM.. Reason: correction - replaced "somewhere else" with "something else"
# 9  
Old 07-25-2017
I will convert several scripts to Perl and we will move them to different server. So there is no impact on others.

Thank you for your advise. I appreciate it.
# 10  
Old 07-25-2017
Quote:
Originally Posted by digioleg54
And as I said, there is no arguments shell script receives
I understand the part about reimplementing it, so my point about not using getopts is moot. The script not getting any arguments, though, is a keen assumption on your part: it might be that the script if called from cron doesn't get any arguments, but it might be called somewhere else (and with arguments, for that matter). You might want to give this thought some consideration, maybe by calling:

Code:
find / -type f -exec /usr/local/bin/checkforscript {} <yourscriptname> \; 2>/dev/null

Where /usr/local/bin/checkforscript looks like:

Code:
#! /bin/ksh

if file "$1" | grep -qi script ; then
     grep "$2" /dev/null "$1"
fi

exit 0

Notice that the added /dev/null in the grep-call makes grep display the filename of the files in which hits are found.

I hope this helps.

bakunin
# 11  
Old 07-25-2017
I am doing it now.

Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

2. Shell Programming and Scripting

sub arguments to shell script

Hi, I have a shell script, when run it i get a prompt to enter arguments say 1 for doing my next task otherwise q for quit. What I am trying to do is run the shell script with the argument passed in however it does not seem to work. This is what I did ./test.sh 1 Instead it printed the line... (6 Replies)
Discussion started by: aqua9
6 Replies

3. Shell Programming and Scripting

Using arguments in Shell script

Hello, I have to make a shell script doing that : the program tests if there is an argument, if there is it checks whether this is a directory or not, If it is it opens it. for any .c file in the directory it prints 2 lines in the screen : the dependence line of the .o and compiler commend... (1 Reply)
Discussion started by: dekl
1 Replies

4. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

5. Shell Programming and Scripting

no of arguments to function in shell script

Hi, I have a function in shell script fun1{ echo "No.of arguments are..."} this function will be called in same script by passing arguments fun 1 2 3 I want to check the no. of arguments passed to fun1 function in the same functionbefore validation. can any one suggest me. (2 Replies)
Discussion started by: KiranKumarKarre
2 Replies

6. Shell Programming and Scripting

Need help to pass arguments to shell script

Hi, I have a shell script called ftp.sh which is running continously in background. I tried passing arguments to this script but it did not worked out. Below is ftp.sh script. Please help me case $param in start) sleep_func "300" echo "!ksh $scr_ddir/ftp.sh... (1 Reply)
Discussion started by: bhargav20
1 Replies

7. Shell Programming and Scripting

passing runtime arguments to a shell script...

hi I am new to shell programming.....my question is while running one of my shell program it stops in between to accept input from the user and proceeds furthur after giving input....I want to know whether I can set this input through some files so that the shell acript reads the input from the... (10 Replies)
Discussion started by: santy
10 Replies

8. Shell Programming and Scripting

Is there a limit to the no. of arguments to a shell script ?

What is the maximum no. of arguments that could be passed to a shell script ? Is there any restriction ? I've a requirement where I need to pass a list of names to a unix script and I guess the number of such names is not a fixed one. It can run into hundreds. Is this feasible ? (4 Replies)
Discussion started by: hidnana
4 Replies

9. Shell Programming and Scripting

Shell script doesn't get executed using crontab

I have the following crontab entry to run a shell script for every 30 minutes of every day: 30 * * * * $HOME/main.sh > $HOME/main.log 2>$HOME/error.log after I created the crontab file I have also done: $crontab my_crontab I also check to make sure it exists, by using the following... (11 Replies)
Discussion started by: radhika
11 Replies

10. Shell Programming and Scripting

Shell script with arguments

Hi All, I need some help/ideas in coming up with a shell script. Basically, the script should install 1 or 2 or 3 packages based on the input arguments. For example, if I type in pkgscript.sh a1 a2 a3, it should install all the 3 scripts and pkgscript.sh a1 should install only a1. If a... (3 Replies)
Discussion started by: sankar6254
3 Replies
Login or Register to Ask a Question