How to pass arguments to bash / python code when executing in bash / python prompt ? [when executing manually (or) in exec mode through SSH]Automatically enter SSH password with scriptHow to pass all arguments passed to my bash script to a function of mine?How to pass variable arguments from bash script to python scriptHow to get a password from a shell script without echoingHow to specify the private SSH-key to use when executing shell command on Git?PHP exec(): Running bash script to configure environment then executing Python programSuppress warning messages using mysql from within Terminal, but password written in bash scriptPass Bash Script Argument to Python Email ScriptExecuting a python script on multpile nodes by using ssh command in BASHExecuting SSH with bash is prompting for passwordHow to add carriage return to bash when prompted for ssh password to localhost?
Probably terminated or laid off soon; confront or not?
What does Argus Filch specifically do?
Why wasn't interlaced CRT scanning done back and forth?
Plotting Autoregressive Functions / Linear Difference Equations
Difference between "jail" and "prison" in German
Is a switch from R to Python worth it?
Would the shaking of an earthquake be visible to somebody in a low-flying aircraft?
Why is the Vasa Museum in Stockholm so Popular?
Is there a way to say "double + any number" in German?
What license to choose for my PhD thesis?
The warlock of firetop mountain, what's the deal with reference 192?
How do people drown while wearing a life jacket?
Need reasons why a satellite network would not work
how to change dot to underline in multiple file-names?
Repeated! Factorials!
Pronouns when writing from the point of view of a robot
Awk to get all my regular users in shadow
What is the reason behind water not falling from a bucket at the top of loop?
split inside flalign
What is the difference between "un plan" and "une carte" (in the context of map)?
Has J.J.Jameson ever found out that Peter Parker is Spider-Man?
Formal mathematical definition of renormalization group flow
A Haskell implementation of Conway's Game of Life, viewable on the console, no external libs
Volcanic 3D masyu
How to pass arguments to bash / python code when executing in bash / python prompt ? [when executing manually (or) in exec mode through SSH]
Automatically enter SSH password with scriptHow to pass all arguments passed to my bash script to a function of mine?How to pass variable arguments from bash script to python scriptHow to get a password from a shell script without echoingHow to specify the private SSH-key to use when executing shell command on Git?PHP exec(): Running bash script to configure environment then executing Python programSuppress warning messages using mysql from within Terminal, but password written in bash scriptPass Bash Script Argument to Python Email ScriptExecuting a python script on multpile nodes by using ssh command in BASHExecuting SSH with bash is prompting for passwordHow to add carriage return to bash when prompted for ssh password to localhost?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am running a script in bash prompt/command line manually. How to pass arguments?
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
I am new to scripting, that's the reason above code is incomplete. Please use any argument in the code. Let's say username and password are the arguments.
One can answer this question in the manual context.
(Just to give you a brief, this is what I am trying to do.
I like to know this and do the same when running the code through SSH in exec mode (or) bash prompt (or) command line (or) python code in python prompt.)
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
Use % symbol as an argument and attach at the end.
mem_utilization=80%
bash shell arguments command-line-arguments
add a comment |
I am running a script in bash prompt/command line manually. How to pass arguments?
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
I am new to scripting, that's the reason above code is incomplete. Please use any argument in the code. Let's say username and password are the arguments.
One can answer this question in the manual context.
(Just to give you a brief, this is what I am trying to do.
I like to know this and do the same when running the code through SSH in exec mode (or) bash prompt (or) command line (or) python code in python prompt.)
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
Use % symbol as an argument and attach at the end.
mem_utilization=80%
bash shell arguments command-line-arguments
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20
add a comment |
I am running a script in bash prompt/command line manually. How to pass arguments?
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
I am new to scripting, that's the reason above code is incomplete. Please use any argument in the code. Let's say username and password are the arguments.
One can answer this question in the manual context.
(Just to give you a brief, this is what I am trying to do.
I like to know this and do the same when running the code through SSH in exec mode (or) bash prompt (or) command line (or) python code in python prompt.)
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
Use % symbol as an argument and attach at the end.
mem_utilization=80%
bash shell arguments command-line-arguments
I am running a script in bash prompt/command line manually. How to pass arguments?
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
I am new to scripting, that's the reason above code is incomplete. Please use any argument in the code. Let's say username and password are the arguments.
One can answer this question in the manual context.
(Just to give you a brief, this is what I am trying to do.
I like to know this and do the same when running the code through SSH in exec mode (or) bash prompt (or) command line (or) python code in python prompt.)
mem_utilization=`free -m | awk 'NR==2printf "%.2fn", $3*100/$2 '`
Note:
Use % symbol as an argument and attach at the end.
mem_utilization=80%
bash shell arguments command-line-arguments
bash shell arguments command-line-arguments
edited Mar 27 at 2:33
Allan
9,9173 gold badges15 silver badges37 bronze badges
9,9173 gold badges15 silver badges37 bronze badges
asked Mar 27 at 1:52
Pavan608Pavan608
191 silver badge4 bronze badges
191 silver badge4 bronze badges
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20
add a comment |
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20
add a comment |
1 Answer
1
active
oldest
votes
For the first part I am not quite sure what you want to do: using your awk-syntax you can append your % with:
mem_utilization=$(free -m | awk 'NR==2printf "%.2fn", $3*100/$2 ')
mem_utilization=$mem_utilization'%'
echo $mem_utilization
you can place this in a shell script to run over SSH with something like
ssh user@pc123456 'bash -s' < local_script.sh
and for the fact that you want to pass arguments to python promts via ssh:
this works just like any other time: use argparse and give the arguments with "path_to_script" -"name of your argument1" ... --"name of your argumentn"
The fact that you want to use a password as an argument is something you have to consider carefully: You could use sshpass. But then PLEASE DO NOT WRITE IT INTO THE SCRIPT. Instead use read to enter the password one time. (compare to this discussion: Automatically enter SSH password with script)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368635%2fhow-to-pass-arguments-to-bash-python-code-when-executing-in-bash-python-prom%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For the first part I am not quite sure what you want to do: using your awk-syntax you can append your % with:
mem_utilization=$(free -m | awk 'NR==2printf "%.2fn", $3*100/$2 ')
mem_utilization=$mem_utilization'%'
echo $mem_utilization
you can place this in a shell script to run over SSH with something like
ssh user@pc123456 'bash -s' < local_script.sh
and for the fact that you want to pass arguments to python promts via ssh:
this works just like any other time: use argparse and give the arguments with "path_to_script" -"name of your argument1" ... --"name of your argumentn"
The fact that you want to use a password as an argument is something you have to consider carefully: You could use sshpass. But then PLEASE DO NOT WRITE IT INTO THE SCRIPT. Instead use read to enter the password one time. (compare to this discussion: Automatically enter SSH password with script)
add a comment |
For the first part I am not quite sure what you want to do: using your awk-syntax you can append your % with:
mem_utilization=$(free -m | awk 'NR==2printf "%.2fn", $3*100/$2 ')
mem_utilization=$mem_utilization'%'
echo $mem_utilization
you can place this in a shell script to run over SSH with something like
ssh user@pc123456 'bash -s' < local_script.sh
and for the fact that you want to pass arguments to python promts via ssh:
this works just like any other time: use argparse and give the arguments with "path_to_script" -"name of your argument1" ... --"name of your argumentn"
The fact that you want to use a password as an argument is something you have to consider carefully: You could use sshpass. But then PLEASE DO NOT WRITE IT INTO THE SCRIPT. Instead use read to enter the password one time. (compare to this discussion: Automatically enter SSH password with script)
add a comment |
For the first part I am not quite sure what you want to do: using your awk-syntax you can append your % with:
mem_utilization=$(free -m | awk 'NR==2printf "%.2fn", $3*100/$2 ')
mem_utilization=$mem_utilization'%'
echo $mem_utilization
you can place this in a shell script to run over SSH with something like
ssh user@pc123456 'bash -s' < local_script.sh
and for the fact that you want to pass arguments to python promts via ssh:
this works just like any other time: use argparse and give the arguments with "path_to_script" -"name of your argument1" ... --"name of your argumentn"
The fact that you want to use a password as an argument is something you have to consider carefully: You could use sshpass. But then PLEASE DO NOT WRITE IT INTO THE SCRIPT. Instead use read to enter the password one time. (compare to this discussion: Automatically enter SSH password with script)
For the first part I am not quite sure what you want to do: using your awk-syntax you can append your % with:
mem_utilization=$(free -m | awk 'NR==2printf "%.2fn", $3*100/$2 ')
mem_utilization=$mem_utilization'%'
echo $mem_utilization
you can place this in a shell script to run over SSH with something like
ssh user@pc123456 'bash -s' < local_script.sh
and for the fact that you want to pass arguments to python promts via ssh:
this works just like any other time: use argparse and give the arguments with "path_to_script" -"name of your argument1" ... --"name of your argumentn"
The fact that you want to use a password as an argument is something you have to consider carefully: You could use sshpass. But then PLEASE DO NOT WRITE IT INTO THE SCRIPT. Instead use read to enter the password one time. (compare to this discussion: Automatically enter SSH password with script)
edited Mar 27 at 11:13
answered Mar 27 at 10:10
Arbor ChaosArbor Chaos
113 bronze badges
113 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368635%2fhow-to-pass-arguments-to-bash-python-code-when-executing-in-bash-python-prom%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Note: No need to save code in the file in this case.
– Pavan608
Mar 27 at 2:10
Note: Could you create a minimal and verifiable example? stackoverflow.com/help/mcve
– Allan
Mar 27 at 2:35
@Pavan608 : Are you looking for something like expect?
– user1934428
Mar 27 at 8:20