我在使用PHP来SFTP上传文件到远程服务器时遇到了麻烦.当我使用cURL时,我收到此处描述的错误:
来自PHP的SFTP - 未定义的常量CURLOPT_PROTOCOLS和CURLPROTO_SFTP?
我也按照以下建议尝试了phpseclib:
但是,当我尝试phpseclib时,我得到这些错误:
Warning: require_once(Math/BigInteger.php) [function.require-once]: failed to open stream: No such file or directory in /home/john/public_html/test/Net/SSH2.php on line 53
Fatal error: require_once() [function.require]: Failed opening required 'Math/BigInteger.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/john/public_html/test/Net/SSH2.php on line 53
Run Code Online (Sandbox Code Playgroud)
然后我尝试在php中使用系统命令,但没有任何反应:
<?php
echo system('sftp user@ftp.domain.com');
echo system('password');
echo system('put file.csv');
?>
Run Code Online (Sandbox Code Playgroud)
我也试过了
<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644);
?>
Run Code Online (Sandbox Code Playgroud)
但是我的php服务器说没有定义ss2_connect.
我试图从终端做以下事情
scp file.csv user@ftp.remote.com
password
Run Code Online (Sandbox Code Playgroud)
但是服务器不允许使用scp命令.我没有shell访问权限来创建ssh密钥.
我现在能做的就是从终端sftp并手动上传.但我真的想自动化这个,所以PHP网站可以做到这一切.
关于如何从PHP上传SFTP的教程并不多.是因为这是一件坏事吗?如果是这样,我该怎么办?我要上传的服务器只允许sftp连接.
我在Delphi Win32中使用FastReport.
调用FastReport时,会在打印之前预览它.
用户有时需要打印一系列报告.这是一个PITA预览,然后分别打印每个.
如何将报告排队并将其直接发送到默认打印机?
IE问题让我完全陷入困境.我有一个coldfusion页面,它使用JQuery的AJAX .load函数加载一个由coldFusion的cfchart标签生成的新flash文件.这在firefox中工作得很好:新的flash文件和新的html元素加载.但是在IE中:加载了所有使用flash对象生成的html元素,除了在IE中运行ajax调用后flash对象和embed标签根本不显示.在查看Fiddler之后,Flash应用程序类型响应数据甚至都不会出现在IE中.但它适用于Firefox.
我想也许它与任何类型的媒体有关,所以我改变了图表类型输出为jpg文件而不是flash.它在IE中完全加载.因此有些事情阻止IE接收闪存响应数据.
这是我到目前为止所做的 - 到目前为止没有运气:
<META
HTTP-EQUIV="CACHE-CONTROL"
CONTENT="NO-CACHE"><META
HTTP-EQUIV="EXPIRES" CONTENT="01 Jan
1970 00:00:00 GMT"><META
HTTP-EQUIV="PRAGMA"
CONTENT="NO-CACHE">任何建议或见解将不胜感激.谢谢你提前谢谢!
我正在构建一个使用MongoDB作为后端的Rails应用程序,使用MongoMapper作为ORM工具.假设在版本1中,我定义了以下模型:
class SomeModel
include MongoMapper::Document
key :some_key, String
end
Run Code Online (Sandbox Code Playgroud)
稍后在版本2中,我意识到我需要在模型上使用新的必需键.因此,在版本2中,SomeModel现在看起来像这样:
class SomeModel
include MongoMapper::Document
key :some_key, String
key :some_new_key, String, :required => true
end
Run Code Online (Sandbox Code Playgroud)
如何迁移所有现有数据以包含some_new_key?假设我知道如何为所有现有文档设置合理的默认值.更进一步,假设在版本3中,我意识到我根本不需要some_key.所以,现在模型看起来像这样
class SomeModel
include MongoMapper::Document
key :some_new_key, String, :required => true
end
Run Code Online (Sandbox Code Playgroud)
但是我的数据库中的所有现有记录都为some_key设置了值,而这只是浪费空间.我该如何收回那个空间?
使用ActiveRecord,我刚刚创建了迁移来添加some_new_key的初始值(在version1 - > version2迁移中)并删除some_key的值(在version2 - > version3迁移中).
使用MongoDB/MongoMapper执行此操作的适当方法是什么?在我看来,仍然需要一些跟踪哪些迁移的方法.这样的事情存在吗?
编辑:我认为人们忽略了我的问题.有时您希望能够在数据库上运行脚本来更改或重构其中的数据.我在上面给出了两个示例,一个是添加了新的必需密钥,另一个是可以删除密钥并且可以回收空间的示例.如何管理运行这些脚本?ActiveRecord迁移为您提供了一种简单的方法来运行这些脚本并确定已运行的脚本以及尚未运行的脚本.我显然可以编写一个Mongo脚本来对数据库进行任何更新,但我正在寻找的是一个像迁移这样的框架,可以跟踪哪些升级脚本已经运行过.
所以我看到Git无法识别文件夹,或者我应该说当提交之间的唯一更改是将空文件夹添加到工作树中时它们git status之后没有显示git add ..
您将如何处理将空文件夹添加到工作树(用于运行时存储)的需要,并在其他存储库从当前存储库(添加了文件夹的存储库)中提取时反映/创建它们?
有这样的功能吗?
如果没有,任何人都有一个?
我需要使用用户的url友好提交字符串,因为我稍后会将其用作我网站上帖子的网址.
谢谢
顺便说一句,它的PHP!
我正在设置我的Authlogic用户会话功能.而且我有些困惑.当我跑:
cucumber features
Run Code Online (Sandbox Code Playgroud)
我收到一些红色错误
Scenario: User signs in successfully # features/user_sessions.feature:21
Given a user exists with login: "sachin", password: "secret" # features/step_definitions/pickle_steps.rb:4
When I go to the login page # features/step_definitions/webrat_steps.rb:15
And I login as "sachin" with password "secret" # features/step_definitions/user_session_setps.rb:5
Then I should see "Login successful" # features/step_definitions/webrat_steps.rb:123
And I should be logged in # features/user_sessions.feature:26
Ambiguous match of "I should be logged in":
features/step_definitions/pickle_steps.rb:55:in `/^((?:(?:I|myself|me|my)|(?:(?:a|an|another|the|that) )?(?:(?:(?:(?:first|last|(?:\d+(?:st|nd|rd|th))) )?(?:user))|(?:(?:user)(?::? "(?:[^\"]|\.)*"))))) should (?:be|have) (?:an? )?((?:duplicable|readonly|nil|store[_ ]full[_ ]sti[_ ]class|new[_ ]record|equal|present|eql|marked[_ ]for[_ ]destruction|valid[_ …Run Code Online (Sandbox Code Playgroud) 谢谢你嘎嘎指出一个一个!
以下代码是我第一次使用Optparse编写代码.
如何在Optparse获取帮助时解决以下错误?
#!/usr/bin/env python
import sys
import os
from optparse import OptionParser
e = sys.argv[1]
b = sys.argv[2]
no = sys.argv[3]
def set_figu(figu):
sum = 777
return sum
def main():
usage = "Usage: negative_bin_base.py <eksponentti> <siirre> <figu>"
parser = OptionParser(usage)
parser.add_option("-h", "--help", dest="help",
help="get synopsis of parameters")
# print the output of the work-horse
print set_figu(no)
(options, args) = parser.parse_args()
if len(args) < 4:
parser.error("incorrect number of arguments")
if options.informative:
print "reading %s..." % options.help
if __name__ == "__main__": …Run Code Online (Sandbox Code Playgroud) 这段代码在Windows Compact Framework上运行,它的作用是显而易见的.看起来它应该被重构(特别是考虑到我可能想稍后添加cmd.ExecuteResultSet()),但我看不到一种优雅的方式来做到这一点.任何想法都赞赏.
internal void RunNonQuery(string query)
{
string connString = GetLocalConnectionString();
using (SqlCeConnection cn = new SqlCeConnection(connString))
{
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
cmd.CommandText = query;
cmd.ExecuteNonQuery();
}
}
internal int RunScalar(string query)
{
string connString = GetLocalConnectionString();
using (SqlCeConnection cn = new SqlCeConnection(connString))
{
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
cmd.CommandText = query;
return int.Parse(cmd.ExecuteScalar().ToString());
}
}
Run Code Online (Sandbox Code Playgroud) 我想要的cmdlet语法是这样的:
cmdletname [foo|bar] p1, p2
Run Code Online (Sandbox Code Playgroud)
cmdletname -foo xxx -p1 hello -p2 world
cmdletname -bar yyy -p1 hello -p2 world
Run Code Online (Sandbox Code Playgroud)
cmdletname -foo xxx -bar yyy -p1 hello -p2 world
Run Code Online (Sandbox Code Playgroud)
php ×2
ajax ×1
arguments ×1
c# ×1
coldfusion ×1
cucumber ×1
debugging ×1
delphi ×1
fastreport ×1
flash ×1
git ×1
html ×1
jquery ×1
migration ×1
mongodb ×1
mongomapper ×1
parameters ×1
phpseclib ×1
powershell ×1
python ×1
refactoring ×1
sftp ×1