2016-04-14 9 views
0

私はファイルシステムをマウントするために、python subprocess.popenコマンドを使用してファイルシステムをマウントしようとしています。スクリプトがどのようにファイルシステムをマウントすることができないのか。pythonサブプロセスpopenを使用してファイルシステムをマウントすることができません

マイスクリプト:私のスクリプトから

self.mountSrc = subprocess.Popen('mount'+' '+ self.src_m[l], shell=True) 

print self.mountSrc 

if self.mountSrc==0: 

    print "Mounted filesystem:"+ self.src_m[l] 

出力:

Mounting: Source Mount Point:/rsyncTesting/source/share1 
Starting:[................................................... ] Done! 

mount: can't find /rsyncTesting/source/share1 in /etc/fstab or /etc/mtab 
1 

私は、mountコマンドを実行する前に/ etc/fstabにファイルシステムのパスを更新しています。また、私はコマンドラインからrootユーザとしてファイルシステムを手動でマウントすることができます。

slcnas888:/export/rsyncScriptProject_Source/rsyncShare1/.zfs/snapshot/SR_0000-0000000_Refresh_rsyncShares_RSYNC_PROJ_exp13April16/rsyncTesting /ソース/ SHARE1

+1

端末から使用するコマンドラインを追加できますか? コードは変数のみを扱い、表示されている出力のいくつかはコードスニペットとは関係がないので、これを適用すると解決策を得るのに役立ちます –

+2

'mount:/ rsyncTesting/source// etc/fstab'のshare1 - それはすべて実際に言う... – isedev

+0

linuxのコマンドラインから、私はコマンドを実行しています: "mount/rsyncTesting/source/share1"これは手動でうまくいきます。私は/ etc/fstabファイルにファイルシステムエントリを追加していますが、正常に動作しますが、pythonサブプロセスでは失敗します。 – Kalyan

答えて

0

私はちょうどマウントポイントの名前が含まれるようにmountコマンドを変更し、
mount /absolute-nas-fs-path /mount-pointすなわちただmount /absolute-nas-fs-pathの代わりに。

/etc/fstabファイルにエントリを追加すると、linuxではmount <mount point path>がシェルからうまく動作しますが、pythonサブプロセスではファイルシステムの絶対パスとコマンドのマウントポイントの両方を渡す必要がありますパラメータ。

# self.src_fs[l] is an item from my list of filesystem paths. 
# self.src_m[l] is an item from my list of mount points. 
self.mountSrc = subprocess.Popen('mount ' + self.src_fs[l] + ' ' + self.src_m[l], shell = True) 
print self.mountSrc 
if self.mountSrc == 0: 
    print "Mounted filesystem:" + self.src_m[l] 
関連する問題