Rajat Sehgal
asked on
How to run a script using passing arguments
Hi Experts,
I,ve a cmd to viewing my application running status in Linux, this is a manual process, i need to run same process using script file ?
Please Suggest.
Proc.jpg
I,ve a cmd to viewing my application running status in Linux, this is a manual process, i need to run same process using script file ?
Please Suggest.
Proc.jpg
ASKER
cat script.sh
#!/bin/bash
OmBabble dd_tplantc
0 1 subscribe 63001 1 abc_od
Output:-
ACE8:/home/aa=>./script.sh
>
The first line only execute...
#!/bin/bash
OmBabble dd_tplantc
0 1 subscribe 63001 1 abc_od
Output:-
ACE8:/home/aa=>./script.sh
>
The first line only execute...
0 is not a command if you need to pass input to the OmBabble... try:
echo 0 1 subscribe 63001 1 abc_od | OmBabble dd_tplantc
or
or save as script.sh
bash ./script.sh 0 1 subscribe 63001 1 abc_od
echo 0 1 subscribe 63001 1 abc_od | OmBabble dd_tplantc
or
#!/bin/bash
OmBabble dd_tplantc <<EOI
0 1 subscribe 63001 1 abc_od
EOI
or save as script.sh
#!/bin/bash
echo $* | OmBabble dd_tplantc
and run bash ./script.sh 0 1 subscribe 63001 1 abc_od
ASKER
unable to execute in both case
cat script.sh
#!/bin/bash
OmBabble dd_tplantc <<EOI
0 1 subscribe 63001 1 abc_od
EOI
Output:-
ACE8:/home/aa=>./script.sh
>>
>>
< 32766 0 32767 1 subscribe
>>>memory map not enabled.
cat script.sh
#!/bin/bash
echo $* | OmBabble dd_tplantc
Output:-
ACE8:/home/aa=>bash ./script.sh 0 1 subscribe 63001 1 abc_od
>
>>
< 32766 0 32767 1 subscribe
>>memory map not enabled.
cat script.sh
#!/bin/bash
OmBabble dd_tplantc <<EOI
0 1 subscribe 63001 1 abc_od
EOI
Output:-
ACE8:/home/aa=>./script.sh
>>
>>
< 32766 0 32767 1 subscribe
>>>memory map not enabled.
cat script.sh
#!/bin/bash
echo $* | OmBabble dd_tplantc
Output:-
ACE8:/home/aa=>bash ./script.sh 0 1 subscribe 63001 1 abc_od
>
>>
< 32766 0 32767 1 subscribe
>>memory map not enabled.
I do not really understand what it is you are trying to do.
Are you trying to use
./script.sh argument1 argument2
That will then use $1 and $2 passed to OmBabble?
You should always test whether the number of arguments passed $# meets your need, exit with an error if it does not.
Are you trying to use
./script.sh argument1 argument2
That will then use $1 and $2 passed to OmBabble?
You should always test whether the number of arguments passed $# meets your need, exit with an error if it does not.
Can you post the help screen of OmBabble please?
Presuming something like
OmBabble --help
OmBabble -h
Is this an OpenManage cli command?
Presuming something like
OmBabble --help
OmBabble -h
Is this an OpenManage cli command?
Then appearantly that "input"in not to be typed to the program...using a keyboard.
Please explain what you want to get accomplished, and HOW OmBabble needs it's input...
Please explain what you want to get accomplished, and HOW OmBabble needs it's input...
No way to guess, as the OmBabble script/executable is unique to your runtime environment.
As @arnold suggested, the likely problem is with your input to this script.
Post the output of this command executed on the command line...
This will tell you if you're passing OmBabble the correct arguments.
Said another way, if OmBabble dies running interactive, running in a bash script will never fix this problem.
As @arnold suggested, the likely problem is with your input to this script.
Post the output of this command executed on the command line...
# First version
echo "0 1 subscribe 63001 1 abc_od" | OmBabble dd_tplantc
# Second version
OmBabble dd_tplantc "0 1 subscribe 63001 1 abc_od"
# Third version
OmBabble dd_tplantc 0 1 subscribe 63001 1 abc_od
This will tell you if you're passing OmBabble the correct arguments.
Said another way, if OmBabble dies running interactive, running in a bash script will never fix this problem.
ASKER
# First version Output:-
ACE8:/home/aa=>echo "0 1 subscribe 63001 1 abc_od" | OmBabble dd_tplantc
>
>>>memory map not enabled.
ACE8:/home/aa=>
# Second version Output:-
ACE8:/home/aa=>OmBabble dd_tplantc "0 1 subscribe 63001 1 abc_od"
babble
[-protocol tcp|ssl|http|raw|ssl_raw|u dp|udp_raw |udp_broad cast|udp_r aw_broadca st|udp_mul ticast|udp _multicast _raw
[-lang mnm|fix|none
[-local_lang mnm|fix|none
[-remote_lang mnm|fix|none
[-proxy proxy_addr]
[-verify]
[-scatter]
[-noauth]
[-daemon]
[-server]
[-dc1 | -dc2 | -hc | -ec]
[-noparse]
[-noprint]
[-terse]
[-hex]
[-replace_char char]
[-english]
[-dont_add_lang]
[-load_fields <definitions_file>]
[-interest_fields '<fid>+'
[-lit]
[-timestamp]
[-name name]
[-put file]
[-put_raw file]
[-spit file]
[-spit_raw file]
[-spit_count count]
[-spit_freq freq]
[-append file]
socket
ACE8:/home/aa=>
# Third version Output:-
ACE8:/home/aa=>OmBabble dd_tplantc 0 1 subscribe 63001 1 abc_od
babble
[-protocol tcp|ssl|http|raw|ssl_raw|u dp|udp_raw |udp_broad cast|udp_r aw_broadca st|udp_mul ticast|udp _multicast _raw
[-lang mnm|fix|none
[-local_lang mnm|fix|none
[-remote_lang mnm|fix|none
[-proxy proxy_addr]
[-verify]
[-scatter]
[-noauth]
[-daemon]
[-server]
[-dc1 | -dc2 | -hc | -ec]
[-noparse]
[-noprint]
[-terse]
[-hex]
[-replace_char char]
[-english]
[-dont_add_lang]
[-load_fields <definitions_file>]
[-interest_fields '<fid>+'
[-lit]
[-timestamp]
[-name name]
[-put file]
[-put_raw file]
[-spit file]
[-spit_raw file]
[-spit_count count]
[-spit_freq freq]
[-append file]
socket
ACE8:/home/aa=>
ACE8:/home/aa=>echo "0 1 subscribe 63001 1 abc_od" | OmBabble dd_tplantc
>
>>>memory map not enabled.
ACE8:/home/aa=>
# Second version Output:-
ACE8:/home/aa=>OmBabble dd_tplantc "0 1 subscribe 63001 1 abc_od"
babble
[-protocol tcp|ssl|http|raw|ssl_raw|u
[-lang mnm|fix|none
[-local_lang mnm|fix|none
[-remote_lang mnm|fix|none
[-proxy proxy_addr]
[-verify]
[-scatter]
[-noauth]
[-daemon]
[-server]
[-dc1 | -dc2 | -hc | -ec]
[-noparse]
[-noprint]
[-terse]
[-hex]
[-replace_char char]
[-english]
[-dont_add_lang]
[-load_fields <definitions_file>]
[-interest_fields '<fid>+'
[-lit]
[-timestamp]
[-name name]
[-put file]
[-put_raw file]
[-spit file]
[-spit_raw file]
[-spit_count count]
[-spit_freq freq]
[-append file]
socket
ACE8:/home/aa=>
# Third version Output:-
ACE8:/home/aa=>OmBabble dd_tplantc 0 1 subscribe 63001 1 abc_od
babble
[-protocol tcp|ssl|http|raw|ssl_raw|u
[-lang mnm|fix|none
[-local_lang mnm|fix|none
[-remote_lang mnm|fix|none
[-proxy proxy_addr]
[-verify]
[-scatter]
[-noauth]
[-daemon]
[-server]
[-dc1 | -dc2 | -hc | -ec]
[-noparse]
[-noprint]
[-terse]
[-hex]
[-replace_char char]
[-english]
[-dont_add_lang]
[-load_fields <definitions_file>]
[-interest_fields '<fid>+'
[-lit]
[-timestamp]
[-name name]
[-put file]
[-put_raw file]
[-spit file]
[-spit_raw file]
[-spit_count count]
[-spit_freq freq]
[-append file]
socket
ACE8:/home/aa=>
So it needs them on the command line and it need specific data....
Please explain what these values are
Paramter Meaning
dd_tplantc .:
0. . . . . . . . . .:
1. . . . . . . . . .:
subscribe . .:
63001 . . . . .:
1. . . . . . . . . .:
abc_od. . . . .:
Then possibly the right option can be added...
Please explain what these values are
Paramter Meaning
dd_tplantc .:
0. . . . . . . . . .:
1. . . . . . . . . .:
subscribe . .:
63001 . . . . .:
1. . . . . . . . . .:
abc_od. . . . .:
Then possibly the right option can be added...
this script is supposed to start a service?
are you trying to create a start/stop script that will be manged when the system starts, and then when the system shutsoff?
are you trying to create a start/stop script that will be manged when the system starts, and then when the system shutsoff?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
./script.sh argument1 argument2
$0. $1. $2
The $@ is the list, $# will return number of elements....