How do I run a Ruby script remotely on Linux machine - ruby

I am connected to a Linux server from my Windows machine using putty. I need to create a ruby file and execute the same. Should I create the Ruby file on my machine or on Linux server? Please advise.

Best workflow in this case would be to write the rb script in whatever environment you want ... many people like developing locally on their own machine (which has advantages), and many prefer developing it remotely on another machine.
Basically write it the same way as you would write any ruby file on your favorite text editor using your favorite method.
Then you upload the rile to the remote machine -- you can use software like WinSCP and then run the script using ssh:
$ ssh (server address)
$ ruby (path to wherever you put the script)

It doesn't matter where you compose the script.
You can either compose it locally or remotely
When you're composing it localy you can do it with your well known GUI-Editor Tools like Notepad or so, but you'll have to upload the file to the server to use it there.
When you're composing it remotely you'll have to use CLI-Editors like nano or ViM for it, but you're able to run it instantly without uploading it
And you can run the script on the remote machine as usual
$ ruby path/to/you/script.rb
assuming ruby is already installed

If you want to execute the ruby file on server you have to create it on the server.

Related

Problems using Rubymine with WSL

I created a debian WSL. I installed Ruby and Rails and all the necessary stuff to make the rails server run.
Now I want to edit my code with Rubymine. What is the best way to accomplish my goal?
Do I have to prepare path mapping and keep the files in sync? Or is there a better way like directly editing the code in debian file system?
Thanks for your help
Under wsl you can access the windows filesystem via mount point. C: is under /mnt/c . So you could write your sourcecode with any windows-editor you like, but only in the windows filesystem. If you wonna start your rails app, go to the directory in the wsl: /mnt/c/Users/oliver/myrailsapp/

Silent/Automated Homebrew Install

I am trying to get homebrew installed remotely on a machine without a terminal open and without ssh access to the machine. Our company uses a Directory-as-a-Service which allows us to remotely push shell scripts to our computers which is great, but it requires the scripts to have no interactivity.
Is there a way to automate the installer and remove the “Press enter to continue” prompt in the install process?
Thanks,
Zach S
The env variable CI seems to silence this prompt:
export CI=1

Unable to create vagrant file (homestead.yaml) on windows

I'm gonna to use vagrant on my windows desktop to develop Laravel project. I have followed all the steps to do that. But it has been failed to create homestead.yaml using bash init.sh command.
Below is the error :
Fakhreddin#Lenovo-PC3 /cygdrive/d/laravel-vagrant/homestead
$ bash init.sh
cp: unwritable ‘/home/Fakhreddin/.homestead/Homestead.yaml’ (mode 0500, r-x------); try anyway?
I'm using Cygwin for simulating Unix terminal in the Windows.
(Copy of the comment I wrote above)
Never used Cygwin in my life, but what I would try is to run it as Administrator and re-try.
Otherwise, you may want to consider changing console client. For example, if you install Git, you should be able to use Unix commands via standard Windows console.
I would seriously point the fault at Cygwin, or its settings. I am a member of a team in which all of us run Homestead on Windows 7, with no problems at all. The difference is, we use native Windows command line.

Check if a python script is running on remote machine

I am running a python script on say machine A. Is there any way to know if the python script is running or not from another machine B from command line? I tried getting the process list from the task manager. But it does not show any information regarding this script though it is running( it only showed cmd through which the script is executing ).
This will be a three step process. Step 1 is only required because you are Windows. If you're Mac or Linux, they already come with Step 1 completed for you. Otherwise, this is completely cross-platform capable.
1) You need to remotely connect from Machine A to Machine B. One extremely popular way of doing this is SSH, which can be installed on Machine A and Machine B. The recommended way to do this is with FreeSSHd, which has been very well documented here: https://serverfault.com/questions/8411/what-is-a-good-ssh-server-to-use-on-windows
2) Install the paramiko SSH library for Python. This will allow you to connect to another machine, and execute any arbitrary command line command. On windows, you just need to install the binaries for paramiko and pycrypto/openssl. This also is well documented on SO here: installing paramiko on Windows
3) Decide how you want to harvest the process list. There are several ways which are well documented here: https://stackoverflow.com/questions/53489/how-do-you-list-all-processes-on-the-command-line-in-windows

Run a windows xp bat script remotely from a ubuntu machine

Is it possible to run a windows xp bat script remotely from a ubuntu machine via command line?
This is possible if you have an ssh server running on the WinXP machine. It is trivial to set up such a server if you have installed Cygwin. This is well described here.
Then from an Ubuntu command line (or cron job) you run
ssh user#winxp command
Make sure your .bat has executable permissions.
I think that the technology you are after is WMI. I see that there is an ubuntu package called wmi-client, which you can sudo apt-get install and attempt to you. Some quick searches and I'm unable to find details, but maybe that will get you somewhere....
You would probably use something like remote desktop, and if you did it that way, it would work, but your question isn't very specific

Resources