scripting

How to get a password from a shell script without echoing

五迷三道 提交于 2019-12-17 05:16:28
问题 I have a script that automates a process that needs access to a password protected system. The system is accessed via a command-line program that accepts the user password as an argument. I would like to prompt the user to type in their password, assign it to a shell variable, and then use that variable to construct the command line of the accessing program (which will of course produce stream output that I will process). I am a reasonably competent shell programmer in Bourne/Bash, but I don

Increase max execution time for php

自古美人都是妖i 提交于 2019-12-17 04:41:12
问题 I have added set_time_limit(0); function to increase execution time but its executing only 2-3 minutes maximum. error_reporting(E_ALL); error_reporting(1); set_time_limit(0); I want to search links from a site wich taking a long lime . Any help would be greatly appreciated. Thanks a lot. 回答1: PHP file (for example, my_lengthy_script.php) ini_set('max_execution_time', 300); //300 seconds = 5 minutes .htaccess file <IfModule mod_php5.c> php_value max_execution_time 300 </IfModule> More

How to send emails via cron job usng PHP mysql

只愿长相守 提交于 2019-12-17 04:32:37
问题 i managed to send multiple emails (check here).i am stuck with sending automated emails via cron. This is what i need - while the admin send emails, i store the message, emails, event date in the database. now i am trying to set a cron job to send emails to all these ids from the table with the message i have as a reminder. i am not familiar with cron job scripting, can anyone help in guiding me the right way to write script that i can place in cron tab. I am planning to send two mails - one

How to redirect the output of a PowerShell to a file during its execution

拟墨画扇 提交于 2019-12-17 04:11:23
问题 I have a PowerShell script for which I would like to redirect the output to a file. The problem is that I cannot change the way this script is called. So I cannot do: .\MyScript.ps1 > output.txt How do I redirect the output of a PowerShell script during its execution? 回答1: Maybe Start-Transcript would work for you. First stop it if it's already running, then start it, and stop it when done. $ErrorActionPreference="SilentlyContinue" Stop-Transcript | out-null $ErrorActionPreference = "Continue

Scripting Language vs Programming Language

一个人想着一个人 提交于 2019-12-17 04:09:27
问题 Can anyone explain the difference between Scripting Language and Programming Language please? Also can you state some examples for each. I have Googled a lot but I always find the best answers from Stack Overflow. 回答1: Scripting languages are programming languages that don't require an explicit compilation step. For example, in the normal case, you have to compile a C program before you can run it. But in the normal case, you don't have to compile a JavaScript program before you run it. So

Shell/Bash shortcut for bulk renaming of files in a folder

我们两清 提交于 2019-12-17 03:54:28
问题 Is there a shortcut in Shell/Bash that can rename all the files in a folder based on a regex or some other criteria. What I am looking for here is in my folder documents, that has let's say a 100 text files with the following naming convention: <longdocumentidentifier>-doc-<counter>.txt. I need to rename all the files with the above given convention to just: doc-<counter>.txt Is there a one-liner that can help me with the above? 回答1: I would suggest something like this: for i in *-doc-*.txt;

How to set current working directory to the directory of the script?

℡╲_俬逩灬. 提交于 2019-12-17 03:44:44
问题 I'm writing a bash script. I need the current working directory to always be the directory that the script is located in. The default behavior is that the current working directory in the script is that of the shell from which I run it, but I do not want this behavior. 回答1: #!/bin/bash cd "$(dirname "$0")" 回答2: The following also works: cd "${0%/*}" The syntax is thoroughly described in this StackOverflow answer. 回答3: Try the following simple one-liners: For all UNIX/OSX/Linux dir=$(cd -P --

Run Java class file from PHP script on a website

别说谁变了你拦得住时间么 提交于 2019-12-17 03:27:14
问题 I have a website and want to be able to allow the user to run a Java file on the server from the website. I want the user to click a button which will run the Java file on the server AND anything printed to standard-out by the Java program will be printed out on the website for the user to see. How can this be done (call Java program from PHP and feed the standard out from the Java file back to the PHP website in real time)? Update: Thanks for the answers on how to run the Java program from

Run Java class file from PHP script on a website

跟風遠走 提交于 2019-12-17 03:26:46
问题 I have a website and want to be able to allow the user to run a Java file on the server from the website. I want the user to click a button which will run the Java file on the server AND anything printed to standard-out by the Java program will be printed out on the website for the user to see. How can this be done (call Java program from PHP and feed the standard out from the Java file back to the PHP website in real time)? Update: Thanks for the answers on how to run the Java program from

Is there replacement for cat on Windows

微笑、不失礼 提交于 2019-12-17 02:54:06
问题 I need to join two binary files with a *.bat script on Windows. How can I achieve that? 回答1: Windows type command works similarly to UNIX cat . Example 1: type file1 file2 > file3 is equivalent of: cat file1 file2 > file3 Example 2: type *.vcf > all_in_one.vcf This command will merge all the vcards into one. 回答2: You can use copy /b like this: copy /b file1+file2 destfile 回答3: If you have control over the machine where you're doing your work, I highly recommend installing GnuWin32. Just