通过终端将PHP生成的CSV文件上传到SFTP服务器(Uploading a PHP generated CSV file to SFTP server via terminal)
我有一个PHP文件,使用以下代码生成CSV文件:
$filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header("Content-disposition: filename=".$filename.".csv"); print $csv_output;
我没有包含创建内容的代码,因为它的工作正常。 我需要做的是使用终端运行此文件并将结果上传到sftp服务器。 我可以在终端连接到服务器。
我一直在终端中使用
php
命令生成生成的CSV。 但是,这不会像在浏览器中运行时那样生成CSV。 它做的是将CSV作为字符串生成。有没有办法将CSV生成为像浏览器这样的文件,以便我可以在终端中获取它并将其上传到SFTP服务器? 或者可以回显出PHP文件生成的字符串,并使用这种命令自己创建CSV:
echo "boo,to,you">file.csv
I have a PHP file which generates a CSV file using the code below:
$filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header("Content-disposition: filename=".$filename.".csv"); print $csv_output;
I've not included the code which creates the content as it does it's job fine. What I need to do is use terminal to run this file and upload the results to an sftp server. I can connect to the server fine in terminal.
I have been using the
php
command in terminal to produce the resulting CSV. This however doesn't produce the CSV like it does when run in the browser. What it does do is produce the CSV as a string.Is there a way to either produce the CSV as a file like the browser so I can grab it in terminal and upload it to the SFTP server? Alternatively is it possible to echo out the string produced from the PHP file and create the CSV myself using this kind of command:
echo "boo,to,you">file.csv
原文:https://stackoverflow.com/questions/27508296
最满意答案
首先, 关闭
animation
库并使用ObjectAnimator库。 它更新,更有用100倍。然后,使用AnimatorSet播放动画。
AnimatorSets
可以按顺序播放动画或按顺序播放动画。 您可以创建动画,并使用AnimatorSet#Builter
或AnimatorSet#playSequentially
将其全部按顺序播放。然后,不要担心垃圾收集和清理。 只要将它们从View中删除,垃圾收集器就会在它准备好时清除它们。 但是,您可以通过每次回收和重新使用ImageView来考虑更高效的策略。 这样你不会不断重建它们。 此外,它可以防止大量沉重,不必要的垃圾收集。 如果动画频繁发生,这只需要考虑。
First, ditch the
animation
library and use the ObjectAnimator library. It's newer and 100x more useful.Then, use an AnimatorSet to play the animations.
AnimatorSets
can play animations either sequentially or in order. You can just create your animations and either use theAnimatorSet#Builter
or theAnimatorSet#playSequentially
to play them all in order.Then, don't worry about the garbage collection and cleanup. Just remove them from View and the garbage collector will clean them up when it's ready. However, you may consider a more efficient strategy by recycling and re-using the ImageViews each time. That way you're not re-building them constantly. Also, it prevents a lot of heavy, unnecessary garbage collecting. This would only need to be considered if the animations happen frequently.
相关问答
更多-
如果要为布局内的视图设置动画,则使用布局动画会更容易。 基本上,您需要加载动画,创建LayoutAnimationController ,设置它的延迟,然后启动动画。 这是一些示例代码。 Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_down); animation.setStartOffset(750L); LayoutAnimationController controller = ...
-
最简单的方法只是注意将视图添加到XML文件的顺序。 文件中的下降意味着在Z轴上更高。 编辑:这是在这里和这里在Android开发人员网站上记录。 (感谢@flightplanner) The easiest way is simply to pay attention to the order in which the Views are added to your XML file. Lower down in the file means higher up in the Z-axis. Edit: T ...
-
按顺序动画android视图(Animate android views in order)[2024-03-12]
首先, 关闭 animation库并使用ObjectAnimator库。 它更新,更有用100倍。 然后,使用AnimatorSet播放动画。 AnimatorSets可以按顺序播放动画或按顺序播放动画。 您可以创建动画,并使用AnimatorSet#Builter或AnimatorSet#playSequentially将其全部按顺序播放。 然后,不要担心垃圾收集和清理。 只要将它们从View中删除,垃圾收集器就会在它准备好时清除它们。 但是,您可以通过每次回收和重新使用ImageView来考虑更高效的策 ... -
你也可以使用带有layout_height =“match_parent”的LinearLayout和垂直方向来解决这个问题 您可以将ListView的layout_height设置为0dp并将layout_weight设置为1 然后它会尝试消耗LinearLayout中的所有剩余空间 I've discovered the solution to my problem but it did not lie where I first suspected after all. The problem was ...
-
Android如何绘制视图(How Android Draws Views)[2021-11-06]
这更像是用于测量孩子的“深度优先”和用于实际绘图的“预先订购”。 父母将首先被抽出,而孩子则被放在父母的顶部。 It's more like "depth-first order" for measuring the children and "pre-order" for the actual drawing. The parent will be drawn first and the children stacked on top of the parent. -
从这个答案我决定研究ObjectAnimator类: Android ObjectAnimator 首先,我确实更改了两个按钮的ToggleButton ,一个名为go100,另一个名为go0,两者都从其currentPosition()滑动搜索条; 到100或0,这是因为他们有更好的逻辑使用,因为如果我没有强制它取消选中,执行动画后toggleButton将保持检查,并且无论哪种方式,它将是一个奇怪的UI行为。 两个按钮都在RelativeLayout之外,包含seekBar重新着色的彩色视图。 按钮xm ...
-
Android充气视图(Android inflating views)[2021-12-08]
我跟你做的一模一样。 我在Java活动中使用组合来实现我的活动中的功能共享。 我认为活动是“上下文”,而不是我的页面中被复制的部分。 因此,当我处于某个特定上下文(活动)中时,我会显示layout1,layout2和layout3以及特定参数,以及依赖于该活动的特定内容。 在另一个活动中,layout1,2或3可能不同,但它们在我的屏幕上始终具有相同的位置。 我通过视图使用组合:我的所有活动都有一个超类(称之为你想要的任何东西,比如ActivityWithCustomLayout ,它包含我作为类成员的所有 ... -
由于您没有发布布局,如果您可以将ViewPager和LinearLayout放在一个布局中(例如在RelativeLayout内),那么您可以为其设置动画。 Since you didn't post your layout, if you can put your ViewPager and LinearLayout in one layout, (for example inside a RelativeLayout) then you can animate that.
-
如何在Android中同时制作动画,缩放和转换视图?(How to animate, scale and transforme Views at same time in Android?)[2022-11-15]
我认为最好的方法是使用场景 ,但它需要Android 4.4.2(API级别19)或更高。 只需更改Layout的weight属性或尝试使用PercentRelativeLayout 。 您需要创建2个布局(场景)并在它们之间切换,并且您不必手动处理所有动画内容。 这里还有一个Android Transitions API向后兼容的库: Transitions Everywhere (如果你的项目的min SDK低于19)。 I think the best approach is to use Scene ... -
Android CursorLoader以特定/特定顺序动态添加视图(Android CursorLoader adding views dynamically in specific/certain order)[2022-03-25]
如何在没有一堆布尔变量的情况下以正确的顺序获取视图? 您需要某种状态控制才能使视图按顺序显示。 我会将视图构造/添加委托给一个控件类,该控件类将具有正确的视图所需的所有信息,并且无论加载器如何完成其工作,都按正确的顺序。 public class ViewDispatcher { public SparseArraymLoadStatuses = new SparseArray (); public SparseArray mDataCurso ...