LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-16-2012, 06:29 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
Modify the script , please help


I have a script which called my_script , it can be used to input one parameter ,

$my_script para1

it works fine in the above case

However , if I input more than one parameter like below ,

$my_script para1 para2 para3 ...

it only accept the first one parameter , the para2 , para3 ... is useless in the above case

can advise if I want the script can run all parameter one-by-one , that means run para1 first , then para2 , then para3 .... how can I do ?
 
Old 10-16-2012, 06:32 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Is this a bash, perl, awk, ??? script?

It might also help if post what you've tried this far.
 
1 members found this post helpful.
Old 10-16-2012, 11:13 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
So the general idea here is you ask us about a script that we have zero idea about. Ask us to change it as it does not do what you want. And provide absolutely no details about the script itself.

Let me just have a quick look at my crystal ball ... I will get back to you.
 
1 members found this post helpful.
Old 10-16-2012, 11:56 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by ust View Post
I have a script which called my_script , it can be used to input one parameter ,

$my_script para1

it works fine in the above case However , if I input more than one parameter like below ,

$my_script para1 para2 para3 ...

it only accept the first one parameter , the para2 , para3 ... is useless in the above case can advise if I want the script can run all parameter one-by-one , that means run para1 first , then para2 , then para3 .... how can I do ?
You can do it by writing the script TO do it. This is your script...you get to make it work however you'd like.

Kind of similar to this thread:
https://www.linuxquestions.org/quest...pt-4175423170/

You've been here NINE YEARS, and keep posting questions like this, without showing any effort on your part. Also, you've been given answers to many similar queries in the past, but don't seem to apply them moving forward. For example:

https://www.linuxquestions.org/quest...er-4175413626/
https://www.linuxquestions.org/quest...te-4175413358/
https://www.linuxquestions.org/quest...column-944377/
https://www.linuxquestions.org/quest...script-946113/

As always, we will be happy to HELP you, but you have to show us what you've done/tried, and follow advice given to you. You've been pointed to MANY bash scripting tutorials in the past, ALL of which can answer the question you just asked. Have you referenced ANY of them?
 
Old 10-16-2012, 12:21 PM   #5
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
thanks reply ,

As the script have password in it , I need to remove it before post it .

But I think it is no need to post the script as I don't want to change anything of my_script , I just would like to have another script to include (run) my_script rather than modify it .

I just would like to run the new script can do my_script para1 , then my_script para2 , then my_script para3 , then .....

Can advise what can I do ?

thanks.
 
Old 10-16-2012, 12:36 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Quote:
Can advise what can I do ?
You seem to be still missing the point. We have already advised you many times and pointed out many tutes to help you further.

If you are not willing to show an effort and advise where you are stuck, other than you can't be bothered, I do not see how we can help further.
 
2 members found this post helpful.
Old 10-16-2012, 01:31 PM   #7
valdinei
LQ Newbie
 
Registered: Jul 2012
Location: Brazil
Distribution: Ubuntu, Freebsd, CentOS
Posts: 17

Rep: Reputation: Disabled
One question ust, your script aways have similar action for all params ?

I thought of something:



Code:
####Here all params listed###
params="param1 param2 param3 param4 param5"

#loop for in all params one per time
for param in $params
do
  my_script $param 
done
echo "Finished"
 
Old 10-16-2012, 02:16 PM   #8
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,158
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Code:
bang.sh
#!/bin/bash
# Purpose:    Inserts #!/bin/bash into a file and makes it executable
# Usage:     scriptname /path/to/file.sh
# Author:     JJ/Habitual
# Date:     Tue Jul 19, 2011
# Disclaimer:    WTFPL
# Edited:       Tue Oct 16, 2012
# Superseded by "au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod a+x <afile> | endif | endif" in ~/.vimrc
MINPARAMS=1

if [ -n "$1" ]
then
echo "#!/bin/bash" > $1
chmod 700 "$1"
fi 

if [ $# -lt "$MINPARAMS" ]
then
  echo Usage: `basename $0` /path/to/script.sh
fi  
exit 0
Specifically documented in the "Positional Parameters" section located here...

HTH and Good Luck!
 
Old 10-16-2012, 04:24 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by grail View Post
You seem to be still missing the point. We have already advised you many times and pointed out many tutes to help you further.
If you are not willing to show an effort and advise where you are stuck, other than you can't be bothered, I do not see how we can help further.
+1....couldn't have said it better.
 
Old 10-16-2012, 04:27 PM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by ust View Post
thanks reply ,
As the script have password in it , I need to remove it before post it .
That's easily done....just remove the password. It's just one work...why is that a problem?
Quote:
But I think it is no need to post the script as I don't want to change anything of my_script , I just would like to have another script to include (run) my_script rather than modify it .
And honestly, I think you're not posting the script, because you don't have one, and want us to write it for you. Which seems to be a recurring theme.
Quote:
I just would like to run the new script can do my_script para1 , then my_script para2 , then my_script para3 , then .....
Can advise what can I do ?
thanks.
Yes...we will AGAIN advise you to read the MANY scripting tutorials you've been pointed to in the past. Re-read the answers given to you NUMEROUS times over the nine-year span you've been asking, and think about how to APPLY that knowledge.
 
Old 10-16-2012, 07:20 PM   #11
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by valdinei View Post
One question ust, your script aways have similar action for all params ?

I thought of something:



Code:
####Here all params listed###
params="param1 param2 param3 param4 param5"

#loop for in all params one per time
for param in $params
do
  my_script $param 
done
echo "Finished"
thanks reply ,

my case is the para name is not the similiar , I do not exactly know the parameter name , so can not be param1 param2 param3 ....
 
Old 10-16-2012, 07:26 PM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
So read the tutorials and your other threads...been covered there many times.

And again...post your script and we can help. Otherwise, LEARN...after nine years, this should be something you can do.
 
1 members found this post helpful.
Old 10-16-2012, 07:34 PM   #13
valdinei
LQ Newbie
 
Registered: Jul 2012
Location: Brazil
Distribution: Ubuntu, Freebsd, CentOS
Posts: 17

Rep: Reputation: Disabled
Show your code here... can have more easy for help
 
Old 10-16-2012, 08:38 PM   #14
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
thanks reply ,

I have modified sth , my script is as below , the program name is .c extension , when run program compile , it only compile the first one parameter ( the first program input program name ) , I just would like to compile all programs when input multiple program name .

#vi my_script
"
PROG=/home/ora_tmp/TMP$$.c
"
program_compile $PROG
"
"

program_compile is a script for compiling program .

Last edited by ust; 10-16-2012 at 11:06 PM.
 
Old 10-17-2012, 12:13 PM   #15
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by ust View Post
thanks reply ,
I have modified sth , my script is as below , the program name is .c extension , when run program compile , it only compile the first one parameter ( the first program input program name ) , I just would like to compile all programs when input multiple program name .

#vi my_script
"
PROG=/home/ora_tmp/TMP$$.c
"
program_compile $PROG
"
"
program_compile is a script for compiling program .
Since you seem to be missing/not understanding things:
  • This is NOT your whole script
  • Yes, we DO understand what you WANT to do...restating it doesn't add anything new.
  • Look at the answers you have been given many, MANY times before.
Again, you have been here for NINE YEARS. You've been given MANY scripting lessons and pointed to many scripting tutorials. Why can't you apply what you've been told, or learn from it???
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify script ust Linux - Newbie 2 05-21-2012 04:57 AM
modify the perl script so that I could apply the script to all the files casualzone Linux - Software 3 05-06-2011 05:23 AM
Modify Perl script to work with txt - Permissions script joangopan Programming 4 09-14-2007 10:20 PM
REQ: Help to modify the following script Rick069 Linux - Software 1 07-01-2007 06:42 PM
which rc.d script does netconf modify? stevesk Slackware 4 07-10-2006 11:10 AM


All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration