Saturday, January 15, 2011

How do I run a process remotely from inside a shell script?

Hello. What I am trying to do is to run the shell script 'ABCDE' on one machine, but use another machine to support it. ABCDE is an all-in-one ripper/encoder/tagger script for turning CD's into digital files. I have one machine which has a fast CD drive, but a slow processor, and another machine with a fast processor but a slow CD drive. I have set up SSH tunneling between the two, and also a SSH-fs, so the ripped files can be shared by both machines.

There is a configuration file in my home directory that allows me to set the path of the encoder. Here are the important lines (there are other relating to CD drive location, output format munging, etc):

OGGENCODERSYNTAX=oggenc         # Specify encoder for Ogg Vorbis

OGGENC=/usr/bin/oggenc          # Path to Ogg Vorbis encoder

OGGENCOPTS='-q 6'               # Options for Ogg Vorbis

OUTPUTTYPE="ogg"                # Type of file to create

When I try to put some indication to the script that the path to the encoder is elsewhere, I get problems.

For example:

OGGENC=`ssh WWW.XXX.YYY.ZZZ /usr/bin/oggenc`

It runs the oggenc command before the rest of the shell script. And of course, since the oggencoder has no input at that moment, it gives an error message, and the program moves on to use a default setting from /etc/abcde.conf.

I have tried any number of combinations of " , ' , , \' , \ , \" , etc, but either it doesn't work at all, or it exectues the oggencoder too early.

Please let me know what I'm doing wrong, or if this can even be done at all.

Thanks so much!

  • Bear with me as I understand your setup.

    If Machine-A is the fast-CD device and Machine-B has the fast-processor.
    You seem to be running the job from Machine-A (to be close to the drive).
    You have shared the file-space such that the ripped files
    can be seen from Machine-B to be encoded and probably tagged too.

    Now your problem is to fire the encoder operation remotely from Machine-A.

    ssh user@Machine-B exec /shared/path/encodeScript /shared/path/$filename
    

    Where,

    • $filename is the file to be encoded and
    • /shared/path is visible across the machines

    should do individual file encoding on the remote Machine-B.

    nik : Your WAV file would be the filename reference. The script could delete the WAV or the caller can delete locally from Machine-A after the encoder remote call returns.
    From nik

0 comments:

Post a Comment