scripting

<script> tag position before <html> tag

点点圈 提交于 2019-12-25 02:19:00
问题 Can a <script> tag between <!DOCTYPE html> and <html> be valid? The reason I ask is I found the code I've described above. Can it be valid under any circumstances? 回答1: No. <html> is the root (or document) element of an HTML document; it must be the only root-level element in an HTML document (it cannot have any siblings). Further, HTML can only contain <head> and <body> (specifically one of each), meaning that any other tags (e.g. <script> must be descendants of <head> or <body> . 回答2: I don

how to stop my php page from continuing when field is empty

冷暖自知 提交于 2019-12-25 02:15:43
问题 <?php if(isset($_POST['submit'])){ echo "wht the heck"; $avail = new CheckEmptyFields(); $avail->availtime=$_POST['available_time']; echo $avail->chkFieldAvailableTime(); } else { print "<font color='red'>*</font>Printing else"; } ?> in my page but when i press continue the page goes on next page while field is empty. beacuse i see "printing else" on the page even b4 i press continue so the script ran before while it should run when the user presses continue button. 回答1: if ($_SERVER['REQUEST

Bash script to display Mac Airport MAC address

此生再无相见时 提交于 2019-12-25 02:09:47
问题 I'm not good at scripting but found this site so hopefully some kind people out there can help me :) I need a bash script to display the Airport Mac Address of machines, I think the command is.. ifconfig en1 ..which brings up the correct result in Terminal but I dont know how to utilise this. I'm using Casper Suite in an office environment and need to get a report that display the MAC address of the wireless (airport) ports. To show you how Casper works here's a script that someone wrote to

What does “variable=${2%?}$i” mean in bash scripting? [duplicate]

萝らか妹 提交于 2019-12-25 01:46:04
问题 This question already has answers here : Syntax with pound and percent sign after shell parameter name (2 answers) Closed last year . Can anyone explain the following bash snippet? for i in $(seq 1 1 10) do VAR=${2%?}$i break; done 回答1: It removes the trailing character from $2 (second positional parameter) and concatenates that value with $i example: $ v1="myvalue1x" $ v2="myvalue2" $ combined="${v1%?}$v2" $ echo $combined myvalue1myvalue2 For more info how the substitution works you can

Monitor folder on remote PC for changed files

感情迁移 提交于 2019-12-25 01:45:52
问题 I have a measuring device on a PC in our network. The PC is not joined to the domain, however has a shared folder for which I have a username and password. I am attempting to build a Powershell script to monitor this folder from a remote server , for new CSV files, the script will then copy the file to a specified folder location. I am struggling to pass through the parameters to the FileSystemWatcher cmdlet. Any ideas? $folder = '\\remoteip\folder\subfolder'# <--'<full path to the folder to

Concatenating text and command output in Bash script to output to file

只谈情不闲聊 提交于 2019-12-25 01:22:18
问题 I'm writing a bash script in FreeBSD that appends commands to a log file. Before I execute the commands that will append the log data, I want to print a line in the file which shows the current date above the data, like this: ---Tue Aug 20 17:26:37 EDT 2019--- I know that I can use the date command to output the timestamp, but I'm not sure how to include the "---" before and after the timestamp to add to the file. What's the simplest way to do this? 回答1: You can pass a format string to date:

Parsing a string with quotes in GETOPTS

好久不见. 提交于 2019-12-25 01:05:10
问题 I am trying to accept a space delimited string in place of $OPTARG while parsing an option For example ./script -k '1 2 ad'ias' As seen the third string can contain any special character. Is there a way that I can overlook the quote in between as I want to parse the entire string and process some options Tried inserting the \ character but that does not work for my case because I cannot insert any character in my string. while getopts "a:k:" option do echo "${option}" case ${option} in a)

Bash script string expansion

给你一囗甜甜゛ 提交于 2019-12-25 00:42:49
问题 I am having an issue with the entering the following command in bash at the moment: RESPONSE=`curl -k "$line" --cert=\"$certfile:$certpassfile\" --silent --write-out --head '%{http_code}\n'` where $line is the url, $certfile is the path to the pem file, $certpassfile is the certificate password. I am getting the following error: ++ curl -k url '--cert="/certpath:certpassword"' --silent --write-out --head '%{http_code}\n' curl: option --cert="/certpath:certpassword": is unknown When i don't

How do I create a batch script that will delete a folder on a scheduled basis?

五迷三道 提交于 2019-12-25 00:19:27
问题 Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I write a batch file to delete folders and files on a time basis? write a batch file to remove the folders by date and time wise. write a script to delete files from a folder which are 5 days older than current date How do I create a batch script that will

How do I output the previous line of a file after searching for a specific line?

拟墨画扇 提交于 2019-12-24 23:02:34
问题 How do I get the previous line of a file after searching for one line? Example: There is a file called fore.dat containing: :Server:APBS :Max Blocking queue:20 :Transport:000 :Server:APBS :Max Transactions:10 :MaxConnections:1 :Transport:001 :Server:APBS :Max Transactions:10 :MaxConnections:1 :Transport:005 :Server:BIT :Max Transactions:10 :Max Connections:1 :Transport:004 :Server:APBS :Max Transactions:44440 :Max Connections:1 :Transport:002 :Server:BET :Max Transactions:10 :Max Connections