[Gluster-users] cp: skipping file $FILEPATH as it was replaced while being copied

Patrick Regan patrick.rubbs.regan at gmail.com
Fri Mar 22 21:11:27 UTC 2013


I have a 8-node 2 replica Gluster volume mounted with the fuse client.
We also have an in-house Perl script we use for doing block string
substitutions. If we run this script on directories on the volume, I
get the following error on almost every file:

cp: skipping file $FILEPATH as it was replaced while being copied

If I mount the volume with NFS, this issue does not arise.

I have also tried to replicate the issue using a roughly equivalent
shell script, but the shell script does not produce the same result on
either the fuse or the nfs client.

I'll paste my volume log followed by the perl script, followed by my
rough shell script.

I would appreciate any feedback.

Thanks!

-------------

[2013-03-22 16:32:52.893362] I [glusterfsd.c:1666:main]
0-/usr/sbin/glusterfs: Started running /usr/sbin/glusterfs version
3.3.1
[2013-03-22 16:32:52.932157] I [io-cache.c:1549:check_cache_size_ok]
0-usrweb-quick-read: Max cache size is 2124763136
[2013-03-22 16:32:52.932634] I [io-cache.c:1549:check_cache_size_ok]
0-usrweb-io-cache: Max cache size is 2124763136
[2013-03-22 16:32:53.035759] I [client.c:2142:notify]
0-usrweb-client-0: parent translators are ready, attempting connect on
transport
[2013-03-22 16:32:53.041228] I [client.c:2142:notify]
0-usrweb-client-1: parent translators are ready, attempting connect on
transport
[2013-03-22 16:32:53.046270] I [client.c:2142:notify]
0-usrweb-client-2: parent translators are ready, attempting connect on
transport
[2013-03-22 16:32:53.050863] I [client.c:2142:notify]
0-usrweb-client-3: parent translators are ready, attempting connect on
transport
Given volfile:
+------------------------------------------------------------------------------+
  1: volume usrweb-client-0
  2:     type protocol/client
  3:     option remote-host ak001
  4:     option remote-subvolume /srv/gluster/volusrweb
  5:     option transport-type tcp
  6: end-volume
  7:
  8: volume usrweb-client-1
  9:     type protocol/client
 10:     option remote-host ak002
 11:     option remote-subvolume /srv/gluster/volusrweb
 12:     option transport-type tcp
 13: end-volume
 14:
 15: volume usrweb-client-2
 16:     type protocol/client
 17:     option remote-host ak003
 18:     option remote-subvolume /srv/gluster/volusrweb
 19:     option transport-type tcp
 20: end-volume
 21:
 22: volume usrweb-client-3
 23:     type protocol/client
 24:     option remote-host ak004
 25:     option remote-subvolume /srv/gluster/volusrweb
 26:     option transport-type tcp
 27: end-volume
 28:
 29: volume usrweb-replicate-0
 30:     type cluster/replicate
 31:     subvolumes usrweb-client-0 usrweb-client-1
 32: end-volume
 33:
 34: volume usrweb-replicate-1
 35:     type cluster/replicate
 36:     subvolumes usrweb-client-2 usrweb-client-3
 37: end-volume
 38:
 39: volume usrweb-dht
 40:     type cluster/distribute
 41:     subvolumes usrweb-replicate-0 usrweb-replicate-1
 42: end-volume
 43:
 44: volume usrweb-write-behind
 45:     type performance/write-behind
 46:     subvolumes usrweb-dht
 47: end-volume
 48:
 49: volume usrweb-read-ahead
 50:     type performance/read-ahead
 51:     subvolumes usrweb-write-behind
 52: end-volume
 53:
 54: volume usrweb-io-cache
 55:     type performance/io-cache
 56:     subvolumes usrweb-read-ahead
 57: end-volume
 58:
 59: volume usrweb-quick-read
 60:     type performance/quick-read
 61:     subvolumes usrweb-io-cache
 62: end-volume
 63:
 64: volume usrweb-md-cache
 65:     type performance/md-cache
 66:     subvolumes usrweb-quick-read
 67: end-volume
 68:
 69: volume usrweb
 70:     type debug/io-stats
 71:     option latency-measurement off
 72:     option count-fop-hits off
 73:     subvolumes usrweb-md-cache
 74: end-volume

+------------------------------------------------------------------------------+
[2013-03-22 16:32:53.057710] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
0-usrweb-client-2: changing port to 24010 (from 0)
[2013-03-22 16:32:53.057895] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
0-usrweb-client-1: changing port to 24010 (from 0)
[2013-03-22 16:32:53.058025] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
0-usrweb-client-0: changing port to 24010 (from 0)
[2013-03-22 16:32:53.059259] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
0-usrweb-client-3: changing port to 24010 (from 0)
[2013-03-22 16:32:56.933277] I
[client-handshake.c:1636:select_server_supported_programs]
0-usrweb-client-2: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:32:56.933966] I
[client-handshake.c:1433:client_setvolume_cbk] 0-usrweb-client-2:
Connected to 10.0.8.242:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:32:56.934012] I
[client-handshake.c:1445:client_setvolume_cbk] 0-usrweb-client-2:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:32:56.934161] I [afr-common.c:3628:afr_notify]
0-usrweb-replicate-1: Subvolume 'usrweb-client-2' came back up; going
online.
[2013-03-22 16:32:56.934400] I
[client-handshake.c:453:client_set_lk_version_cbk] 0-usrweb-client-2:
Server lk version = 1
[2013-03-22 16:32:56.938890] I
[client-handshake.c:1636:select_server_supported_programs]
0-usrweb-client-1: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:32:56.939504] I
[client-handshake.c:1433:client_setvolume_cbk] 0-usrweb-client-1:
Connected to 10.0.8.241:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:32:56.939553] I
[client-handshake.c:1445:client_setvolume_cbk] 0-usrweb-client-1:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:32:56.939685] I [afr-common.c:3628:afr_notify]
0-usrweb-replicate-0: Subvolume 'usrweb-client-1' came back up; going
online.
[2013-03-22 16:32:56.939940] I
[client-handshake.c:453:client_set_lk_version_cbk] 0-usrweb-client-1:
Server lk version = 1
[2013-03-22 16:32:56.944004] I
[client-handshake.c:1636:select_server_supported_programs]
0-usrweb-client-0: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:32:56.944408] I
[client-handshake.c:1433:client_setvolume_cbk] 0-usrweb-client-0:
Connected to 10.0.8.240:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:32:56.944502] I
[client-handshake.c:1445:client_setvolume_cbk] 0-usrweb-client-0:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:32:56.945219] I
[client-handshake.c:453:client_set_lk_version_cbk] 0-usrweb-client-0:
Server lk version = 1
[2013-03-22 16:32:56.949911] I
[client-handshake.c:1636:select_server_supported_programs]
0-usrweb-client-3: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:32:56.950480] I
[client-handshake.c:1433:client_setvolume_cbk] 0-usrweb-client-3:
Connected to 10.0.8.243:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:32:56.950524] I
[client-handshake.c:1445:client_setvolume_cbk] 0-usrweb-client-3:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:32:56.998230] I [fuse-bridge.c:4191:fuse_graph_setup]
0-fuse: switched to graph 0
[2013-03-22 16:32:56.998706] I
[client-handshake.c:453:client_set_lk_version_cbk] 0-usrweb-client-3:
Server lk version = 1
[2013-03-22 16:32:56.999145] I [fuse-bridge.c:3376:fuse_init]
0-glusterfs-fuse: FUSE inited with protocol versions: glusterfs 7.13
kernel 7.10
[2013-03-22 16:32:57.000718] I
[afr-common.c:1965:afr_set_root_inode_on_first_lookup]
0-usrweb-replicate-0: added root inode
[2013-03-22 16:32:57.001914] I
[afr-common.c:1965:afr_set_root_inode_on_first_lookup]
0-usrweb-replicate-1: added root inode
[2013-03-22 16:42:00.074968] I [glusterfsd-mgmt.c:65:mgmt_cbk_spec]
0-mgmt: Volume file changed
[2013-03-22 16:42:02.114686] I [io-cache.c:1549:check_cache_size_ok]
1-usrweb-quick-read: Max cache size is 2124763136
[2013-03-22 16:42:02.114945] I [io-cache.c:1549:check_cache_size_ok]
1-usrweb-io-cache: Max cache size is 2124763136
[2013-03-22 16:42:02.265593] I [client.c:2142:notify]
1-usrweb-client-0: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.270654] I [client.c:2142:notify]
1-usrweb-client-1: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.275012] I [client.c:2142:notify]
1-usrweb-client-2: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.279133] I [client.c:2142:notify]
1-usrweb-client-3: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.283267] I [client.c:2142:notify]
1-usrweb-client-4: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.287310] I [client.c:2142:notify]
1-usrweb-client-5: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.291472] I [client.c:2142:notify]
1-usrweb-client-6: parent translators are ready, attempting connect on
transport
[2013-03-22 16:42:02.295771] I [client.c:2142:notify]
1-usrweb-client-7: parent translators are ready, attempting connect on
transport
Given volfile:
+------------------------------------------------------------------------------+
  1: volume usrweb-client-0
  2:     type protocol/client
  3:     option remote-host ak001
  4:     option remote-subvolume /srv/gluster/volusrweb
  5:     option transport-type tcp
  6: end-volume
  7:
  8: volume usrweb-client-1
  9:     type protocol/client
 10:     option remote-host ak002
 11:     option remote-subvolume /srv/gluster/volusrweb
 12:     option transport-type tcp
 13: end-volume
 14:
 15: volume usrweb-client-2
 16:     type protocol/client
 17:     option remote-host ak003
 18:     option remote-subvolume /srv/gluster/volusrweb
 19:     option transport-type tcp
 20: end-volume
 21:
 22: volume usrweb-client-3
 23:     type protocol/client
 24:     option remote-host ak004
 25:     option remote-subvolume /srv/gluster/volusrweb
 26:     option transport-type tcp
 27: end-volume
 28:
 29: volume usrweb-client-4
 30:     type protocol/client
 31:     option remote-host ak005
 32:     option remote-subvolume /srv/gluster/volusrweb
 33:     option transport-type tcp
 34: end-volume
 35:
 36: volume usrweb-client-5
 37:     type protocol/client
 38:     option remote-host ak006
 39:     option remote-subvolume /srv/gluster/volusrweb
 40:     option transport-type tcp
 41: end-volume
 42:
 43: volume usrweb-client-6
 44:     type protocol/client
 45:     option remote-host ak007
 46:     option remote-subvolume /srv/gluster/volusrweb
 47:     option transport-type tcp
 48: end-volume
 49:
 50: volume usrweb-client-7
 51:     type protocol/client
 52:     option remote-host ak008
 53:     option remote-subvolume /srv/gluster/volusrweb
 54:     option transport-type tcp
 55: end-volume
 56:
 57: volume usrweb-replicate-0
 58:     type cluster/replicate
 59:     subvolumes usrweb-client-0 usrweb-client-1
 60: end-volume
 61:
 62: volume usrweb-replicate-1
 63:     type cluster/replicate
 64:     subvolumes usrweb-client-2 usrweb-client-3
 65: end-volume
 66:
 67: volume usrweb-replicate-2
 68:     type cluster/replicate
 69:     subvolumes usrweb-client-4 usrweb-client-5
 70: end-volume
 71:
 72: volume usrweb-replicate-3
 73:     type cluster/replicate
 74:     subvolumes usrweb-client-6 usrweb-client-7
 75: end-volume
 76:
 77: volume usrweb-dht
 78:     type cluster/distribute
 79:     subvolumes usrweb-replicate-0 usrweb-replicate-1
usrweb-replicate-2 usrweb-replicate-3
 80: end-volume
 81:
 82: volume usrweb-write-behind
 83:     type performance/write-behind
 84:     subvolumes usrweb-dht
 85: end-volume
 86:
 87: volume usrweb-read-ahead
 88:     type performance/read-ahead
 89:     subvolumes usrweb-write-behind
 90: end-volume
 91:
 92: volume usrweb-io-cache
 93:     type performance/io-cache
 94:     subvolumes usrweb-read-ahead
 95: end-volume
 96:
 97: volume usrweb-quick-read
 98:     type performance/quick-read
 99:     subvolumes usrweb-io-cache
100: end-volume
101:
102: volume usrweb-md-cache
103:     type performance/md-cache
104:     subvolumes usrweb-quick-read
105: end-volume
106:
107: volume usrweb
108:     type debug/io-stats
109:     option latency-measurement off
110:     option count-fop-hits off
111:     subvolumes usrweb-md-cache
112: end-volume

+------------------------------------------------------------------------------+
[2013-03-22 16:42:02.301090] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-0: changing port to 24010 (from 0)
[2013-03-22 16:42:04.158794] E
[client-handshake.c:1717:client_query_portmap_cbk] 1-usrweb-client-5:
failed to get the port number for remote subvolume
[2013-03-22 16:42:04.159003] I [client.c:2090:client_rpc_notify]
1-usrweb-client-5: disconnected
[2013-03-22 16:42:04.159074] E
[client-handshake.c:1717:client_query_portmap_cbk] 1-usrweb-client-7:
failed to get the port number for remote subvolume
[2013-03-22 16:42:04.159223] I [client.c:2090:client_rpc_notify]
1-usrweb-client-7: disconnected
[2013-03-22 16:42:04.161765] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-3: changing port to 24010 (from 0)
[2013-03-22 16:42:04.161868] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-2: changing port to 24010 (from 0)
[2013-03-22 16:42:04.162355] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-1: changing port to 24010 (from 0)
[2013-03-22 16:42:04.162449] E
[client-handshake.c:1717:client_query_portmap_cbk] 1-usrweb-client-6:
failed to get the port number for remote subvolume
[2013-03-22 16:42:04.162529] E
[client-handshake.c:1717:client_query_portmap_cbk] 1-usrweb-client-4:
failed to get the port number for remote subvolume
[2013-03-22 16:42:04.162625] I [client.c:2090:client_rpc_notify]
1-usrweb-client-4: disconnected
[2013-03-22 16:42:04.162708] E [afr-common.c:3665:afr_notify]
1-usrweb-replicate-2: All subvolumes are down. Going offline until
atleast one of them comes back up.
[2013-03-22 16:42:04.162765] I [client.c:2090:client_rpc_notify]
1-usrweb-client-6: disconnected
[2013-03-22 16:42:04.162805] E [afr-common.c:3665:afr_notify]
1-usrweb-replicate-3: All subvolumes are down. Going offline until
atleast one of them comes back up.
[2013-03-22 16:42:05.715027] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-0: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:05.715447] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-0:
Connected to 10.0.8.240:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:05.715501] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-0:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:05.715767] I [afr-common.c:3628:afr_notify]
1-usrweb-replicate-0: Subvolume 'usrweb-client-0' came back up; going
online.
[2013-03-22 16:42:05.715836] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-0:
Server lk version = 1
[2013-03-22 16:42:07.722528] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-5: changing port to 24010 (from 0)
[2013-03-22 16:42:07.727863] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-7: changing port to 24010 (from 0)
[2013-03-22 16:42:07.732813] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-3: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:07.733314] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-3:
Connected to 10.0.8.243:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:07.733358] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-3:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:07.733524] I [afr-common.c:3628:afr_notify]
1-usrweb-replicate-1: Subvolume 'usrweb-client-3' came back up; going
online.
[2013-03-22 16:42:07.733731] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-3:
Server lk version = 1
[2013-03-22 16:42:07.738423] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-2: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:07.738819] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-2:
Connected to 10.0.8.242:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:07.738860] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-2:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:07.739276] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-2:
Server lk version = 1
[2013-03-22 16:42:07.744321] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-1: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:07.744874] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-1:
Connected to 10.0.8.241:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:07.744916] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-1:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:07.798486] I [fuse-bridge.c:4191:fuse_graph_setup]
0-fuse: switched to graph 1
[2013-03-22 16:42:07.799081] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-1:
Server lk version = 1
[2013-03-22 16:42:07.799444] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-6: changing port to 24010 (from 0)
[2013-03-22 16:42:07.799591] I [rpc-clnt.c:1657:rpc_clnt_reconfig]
1-usrweb-client-4: changing port to 24010 (from 0)
[2013-03-22 16:42:10.771491] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-5: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:10.776211] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-5:
Connected to 10.0.8.245:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:10.776323] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-5:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:10.776500] I [afr-common.c:3628:afr_notify]
1-usrweb-replicate-2: Subvolume 'usrweb-client-5' came back up; going
online.
[2013-03-22 16:42:10.776836] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-5:
Server lk version = 1
[2013-03-22 16:42:10.777113] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-7: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:10.777615] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-7:
Connected to 10.0.8.247:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:10.777676] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-7:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:10.777866] I [afr-common.c:3628:afr_notify]
1-usrweb-replicate-3: Subvolume 'usrweb-client-7' came back up; going
online.
[2013-03-22 16:42:10.778129] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-7:
Server lk version = 1
[2013-03-22 16:42:11.784150] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-6: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:11.787025] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-6:
Connected to 10.0.8.246:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:11.787141] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-6:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:11.788193] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-6:
Server lk version = 1
[2013-03-22 16:42:11.789908] I
[client-handshake.c:1636:select_server_supported_programs]
1-usrweb-client-4: Using Program GlusterFS 3.3.1, Num (1298437),
Version (330)
[2013-03-22 16:42:11.790334] I
[client-handshake.c:1433:client_setvolume_cbk] 1-usrweb-client-4:
Connected to 10.0.8.244:24010, attached to remote volume
'/srv/gluster/volusrweb'.
[2013-03-22 16:42:11.790398] I
[client-handshake.c:1445:client_setvolume_cbk] 1-usrweb-client-4:
Server and Client lk-version numbers are not same, reopening the fds
[2013-03-22 16:42:11.790726] I
[client-handshake.c:453:client_set_lk_version_cbk] 1-usrweb-client-4:
Server lk version = 1

------------------------------

#!/usr/bin/perl

open(FIND, "find . -print |") || die "Coundn't run find: $!\n";

$counter = 0;
FILE:
while ($filename = <FIND>)
{
chop $filename;
next FILE unless -T$filename;
if(!open(TEXTFILE, "$filename"))
{
print STDERR "Can't open $filename - continuing...\n";
next FILE;
}
while (<TEXTFILE>)
{
$tempfile[$counter] = $_;
$counter = $counter + 1;
if (index($tempfile[$counter - 1],$ARGV[0]) >= 0)
{
$totalchanges = $totalchanges +1;
$dummy=`cp -p $filename blocktemp.txt\n`;
print $dummy;
print "$filename\n";
open(TEMPFILE, "> blocktemp.txt");
$tempfile[$counter -1] =~ s/$ARGV[0]/$ARGV[1]/g;
for($i = 0; $i < $counter; $i++)
{
print TEMPFILE "$tempfile[$i]";
}
while (<TEXTFILE>)
{
$storage = $_;
if (index($storage,$ARGV[0]) >= 0)
{
$storage =~ s/$ARGV[0]/$ARGV[1]/g;
$totalchanges = $totalchanges +1;
}
print TEMPFILE "$storage";
}
close(TEXTFILE);
close(TEMPFILE);
$dummy2=`cp -p blocktemp.txt $filename`;
print $dummy2;
$dummy3=`rm blocktemp.txt`;
print $dummy3;
}
}
close(TEXTFILE);
$counter = 0;
}
print "$totalchanges lines changed\n";

---------------------------

#!/bin/bash

FILES=$(find . -type f)

for f in $FILES
do
cp -p $f tempfile.tmp
sed -i "s/$1/$2/g" tempfile.tmp
cp -p tempfile.tmp $f
rm tempfile.tmp
done

--
Patrick Regan



More information about the Gluster-users mailing list