I'm trying to apply a module patch using SSH.

When I enter the following command:

patch < htdocs / module / smtp / smtp.module.patch

I keep getting the following message:

patch: /: extra operand
patch: Try `patch --help' for more information.

I'm brand new to ssh. Can anyone help?


Haza’s picture

You may read : http://drupal.org/patch/apply

Don't leave space betwen /, it's a path, no space allowed.


mbull’s picture

Ok. Thank you. I've read loads of stuff and managed to get thus far.

I've just taken your first piece of advice and had the following results:

missing header for unified diff at line 8 of patch
(Stripping trailing CRs from patch.)
can't find file to patch at input line 8
Perhaps you should have used the -p or --strip option?
The text leading up to this was:


--- smtp.module     2008-01-15 18:11:30.000000000 -0500
|+++ /home/greg/workspace/smtp/smtp.module      2008-01-28 01:35:22.000000000 -0500

Are you able to help further?
Haza’s picture

Provided that the patch was made relative to the Drupal root directory, navigate to the Drupal directory (using cd) and issue the command:
patch -p0 < path/file.patch

If the patch was not made relative to the Drupal root directory you can place the patch in the same directory as the file being patched and run the patch command without the -p option. To do so, cd to the directory and type:

patch < file.patch

Assuming you got a smtp.module file at the current directory, try

patch -p0 < htdocs/module/smtp/smtp.module.patch
mbull’s picture

It seems that any reference to anything within @@ @@ comes back as an unknown file path.

Should I be replacing (for example @@ -2,9 +2,5 @@) with the file name or is it referencing another piece of Drupal coding elsewhere?

yupthatguy’s picture

I am a newbie.. trying to patch the kwresearch module via a secure shell... I have uploaded the patch file directly to the kwresearch module directory, but without fail.. all I get is command not found:

patch < kwresearch.module.patch

any idea what I am doing wrong?


Jaypan’s picture

It sounds like the patch command is not installed on your system. Contact your hosts and ask them.

I will soon be leaving the Drupal forums permanently. To understand why, please see this thread.