I'm trying to make plink use the private key using the commnand line -i instead of relying on pagent in a ANT CVS task. I tried to set the cvsRsh param to "plink.exe -i my_private_key" without success. It complains that program cannot be found.
Of course i tried all sorts of quotes combination but it seems it tries to validate the path instead of just executing the cvsRsh variable.
So you have any ideas how to accomplish the same thing ?
Related
I have a shell script file in the rails application.Can anyone please tell me how can i call the shell script file with argument in my rails controller?
Thanks
Try backticks (``). For example a = `date` would assign shell's date command output to the a variable.
UPD: And you can obviously run something like `~/workspace/my_script.sh` to execute a script from a file, just make sure you give it executable permission first (with chmod +x ~/workspace/my_script.sh).
UPD2: And for the parameters, you can just interpolate them, like so `~/workspace/my_script.sh #{my_parameter_one}`. my_parameter_one will be available in the script as $1.
I want to do the following commands in ruby.
ssh into another computer using ssh example#example
set source file source ~/.profile
cd to/some/folder
call my shell script with parameters, a json formatted string ,./my_script.sh my_hash.to_json
However I am facing these problems:
I call them in one line using backticks, it works, but it is a very bad practice in my opinion because it is not readable nor it is maintainable.
On the other hand, when I call my_hash.to_json, the resulted string has non-escaped double quotes, How do I escape them?
I would recommend to view this tutorial for ssh with ruby. then make a shell script and move it to server and then execute like a single command.
create a single shell script file for example script1 and then execute it at once instead of executing each command individually.
open file script1 using any editor.
copy all commands to script1 (each command in new line).
script1 file should look like this
#!/bin/bash
ssh example#example
source ~/.profile
cd to/some/folder
save file
make this file executable using chmod +x script
execute it in ruby like this [backtick]./script1[backtick]
note: copy script1 to usr/bin to avoid "./" and then try command only script1.
Reference for passing arguments in shell script is here.
I'm using PBSPro and am trying to use qsub command line to submit a job but can't seem to get the output and error files to be named how I want them. Currently using:
qsub -N ${subjobname_short} \
-o ${path}.o{$PBS_JOBID} -e ${path}.e${PBS_JOBID}
... submission_script.sc
Where $path=fulljobname (i.e. more than 15 characters)
I'm aware that $PBS_JOBID won't be set until after the job is submitted...
Any ideas?
Thanks
The solution I came up with was following the qsub command with a qalter command like so:
jobid=$(qsub -N ${subjobname_short} submission_script.sc)
qalter -o ${path}.o{$jobid} -e ${path}.e${jobid} ${jobid}
This way, PBS Pro does not need to resolve the variables, as it failed to do so in our install (this may be a configuration issue)
If you want the ${PBS_JOBID} to be resolved by PBSPro, you need to escape it on the command line:
qsub -o \$PBS_JOBID
Otherwise, bash will attempt to resolve $PBS_JOBID before it gets to the qsub command. I don't know if $subjobname_short and $path are actual environment variables or ones you want pbs to resolve, but if you want pbs to resolve them you'll also need to escape these ones or place it inside the job script.
NOTE: I also notice that your -o argument says {$PBS_JOBID} and I'm pretty sure you want ${PBS_JOBID}. I don't know if that's a typo in the question or what you tried to pass to qsub.
I try to execute shell commands in rails using the following:
result = `which wkhtmltoimage-proxy`
but I always get back:
No such file or directory - which wkhtmltoimage-proxy
If I just type the command in my shell, everything works but not in the rails environment.
Doesn't matter which commands I try, none of the work.
Do I need to configure anything in rails?
I figured it out. I am using an IDE tool and didn't set the environment variables correctly. Anyways, the problem is solved now. Thanks for all your help!
Think of the system ticks (`) as executing in your rails directory (i.e. 'myapp')
So, if you're expecting to run this command in another directory, such as your home folder, you'll have to specify that
result = `cd ~ && which wkhtmltoimage-proxy`
If this is on Windows
This is spec. Ruby doesn't execute any child process in such case on
Windows, so, ruby cannot set any status to $?.
bugs.ruby-lang.org/issues/1690
This would be part of a reverse-engineering project.
To determine and document what a shell script (ksh, bash, sh) does, it is comfortable, if you have information about what other programs/scripts it calls.
How could one automate this task? Do you know any program or framework that can parse a shell script? This way for instance, I could recognize external command calls -- a step to the right direction.
For bash/sh/ksh, I think you can easily modify their source to log what has been executed. That would be a solution.
How about:
Get a list of distinct words in that script
Search $PATH to find a hit for each
?
bash -v script.sh ?
Bash's xtrace is your friend.
You can invoke it with:
set -x at the top of your script,
by calling your script with bash -x (or even bash --debugger -x),
or recursively by doing (set -x; export SHELLOPTS; your-script; )
If you can't actually run the script, try loading it into a text editor that supports syntax highlighting for Bash. It will color-code all of the text and should help indicate what is a reserved word, variable, external command, etc.