echo

批量添加用户脚本--Linux bash

随声附和 提交于 2020-01-07 13:13:56
脚本实例 批量用户添加 for 在读取文件时,任何空白字符都可以自动作为分隔符、while的按行读取使用的是换行符作为标记,所以在这使用while更好 majun@instance-zqtg07w6:~/bash_scripts$ vim useradd_while02.sh majun@instance-zqtg07w6:~/bash_scripts$ vim users.txt majun@instance-zqtg07w6:~/bash_scripts$ cat users.txt username001 password001 username002 password002 username003 password003 username004 password004 usernmae005 paswword005 majun@instance-zqtg07w6:~/bash_scripts$ cat useradd_while02.sh #!/bin/bash while read LINES do USERNAME = ` echo $LINES | cut -f1 -d ' ' ` PASSWORD = ` echo $LINES | cut -f2 -d ' ' ` echo -n "Username: $USERNAME PASSWORD: $PASSWORD "

Shell 参数扩展及各类括号在 Shell 编程中的应用

本秂侑毒 提交于 2020-01-07 09:30:17
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 今天看有人总结了 shell 下的参数扩展,但不是很全,恰好以前整理过放在百度空间,但百度空间目前半死不活的情况下对 Google 非常不友好,索性一并转过来方便查阅。 1、bash 中的 大括号参数扩展 (Parameter Expansion) 假设我们定义了一个变量为: file=/dir1/dir2/dir3/my.file.txt 1.1 bash 下的 split 取“数组”的首、尾: ${file#*/}:拿掉第一条 / 及其左边的字符串:dir1/dir2/dir3/my.file.txt ${file##*/}:拿掉最后一条 / 及其左边的字符串:my.file.txt ${file#*.}:拿掉第一个 . 及其左边的字符串:file.txt ${file##*.}:拿掉最后一个 . 及其左边的字符串:txt ${file%/*}:拿掉最后条 / 及其右边的字符串:/dir1/dir2/dir3 ${file%%/*}:拿掉第一条 / 及其右边的字符串:(空值) ${file%.*}:拿掉最后一个 . 及其右边的字符串:/dir1/dir2/dir3/my.file ${file%%.*}:拿掉第一个 . 及其右边的字符串:/dir1/dir2/dir3/my Tips: 记忆的方法为: #

echo输出颜色

落爺英雄遲暮 提交于 2020-01-07 07:15:05
语法介绍: echo -e "\e[31m 输入的内容 \e[0m" #输出内容为红色 示例: # 字颜色: 30--37   echo -e "\033[30m 黑颜色字 \033[0m"   echo -e "\033[31m 红颜色字 \033[0m"   echo -e "\033[32m 绿颜色字 \033[0m"   echo -e "\033[33m 黄颜色字 \033[0m"   echo -e "\033[34m 蓝颜色字 \033[0m"   echo -e "\033[35m 紫颜色字 \033[0m"   echo -e "\033[36m 天蓝颜色字 \033[0m"   echo -e "\033[37m 白颜色字 \033[0m" # 字背景颜色范围:40—–47   echo -e "\033[40;37m 黑底白字 \033[0m"   echo -e "\033[41;37m 红底白字 \033[0m"   echo -e "\033[42;37m 绿底白字 \033[0m"   echo -e "\033[43;37m 黄底白字 \033[0m"   echo -e "\033[44;37m 蓝底白字 \033[0m"   echo -e "\033[45;37m 紫底白字 \033[0m"   echo -e "\033[46;37m

Windows telnet + controlling local echo from remote

 ̄綄美尐妖づ 提交于 2020-01-07 06:55:12
问题 I have the same problem as How to unsupress local echo but none of the solutions in that thread are desirable. Specifically, I'm using telnet for communication with a simply Ruby program that requires authentication to connect remotely. When the user is prompted for a password I want to suppress local echo, so I send the password prompt followed by IAC DONT ECHO, then send IAC DO ECHO after receiving a newline. This method appears to work fine for most telnet clients, but when using windows

Digest mimatch for sha256

夙愿已清 提交于 2020-01-07 02:52:07
问题 I am trying to encode the string abc using sha256 and below is the output I got. ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad But, if I use the command openssl sha256 -hex on Linux command line, I get the below output for the same string. edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb Why is there a difference in the outputs? Where am I doing wrong? 来源: https://stackoverflow.com/questions/39307192/digest-mimatch-for-sha256

what's the difference between return/echo json_encode in php [closed]

不打扰是莪最后的温柔 提交于 2020-01-06 23:51:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . maybe this is a simple and stupid question. As we know, echo just print the variable out, and in a php function return statnds for return something to the function invoker. I notice someone use echo json_encode while others using return json_encode , I return something to jquery, and using echo/return are both

How do I completely overwrite previously edited data such that only the latest one is displayed in Codeigniter?

a 夏天 提交于 2020-01-06 23:44:20
问题 I have checked all other related posts but 'could not find any that answers my specific question. Here's what I have: <input name="job_id" type="hidden" value="<?= $this->uri->segment(3, 0); ?>" /> <?php foreach ($my_preference as $row) : if ( $row['status'] == "Open" ) { $bgcolor = "#ADD8E6"; } else if ( $row['status'] == "Approved" ) { $bgcolor = "#8CBEE8"; } else { $bgcolor = "#EDC2B6"; } ?> <span style="font-size: 11pt" class="label label-info"> Proposal</span>     <strong><?= $row[

How can you put PHP inside a Javascript?

那年仲夏 提交于 2020-01-06 17:47:15
问题 I am retrieving a Facebook Page Like count via a PHP function like this: <?php function fbLikeCount($id,$appid,$appsecret){ $json_url ='https://graph.facebook.com/'.$id.'?access_token='.$appid.'|'.$appsecret.'&fields=likes'; $json = file_get_contents($json_url); $json_output = json_decode($json); if($json_output->likes){ return $likes = $json_output->likes; }else{ return 0; } } ?> Then, I am able to echo this out no problem like this: <?php echo number_format(fbLikeCount('companynamegoeshere'

How can you put PHP inside a Javascript?

你说的曾经没有我的故事 提交于 2020-01-06 17:47:12
问题 I am retrieving a Facebook Page Like count via a PHP function like this: <?php function fbLikeCount($id,$appid,$appsecret){ $json_url ='https://graph.facebook.com/'.$id.'?access_token='.$appid.'|'.$appsecret.'&fields=likes'; $json = file_get_contents($json_url); $json_output = json_decode($json); if($json_output->likes){ return $likes = $json_output->likes; }else{ return 0; } } ?> Then, I am able to echo this out no problem like this: <?php echo number_format(fbLikeCount('companynamegoeshere'

批处理Mysql的安装与初始化

霸气de小男生 提交于 2020-01-06 16:04:07
使用的Mysql版本: mysql-5.7.18-win32 免安装版 计算机环境 win7 项目需求 实现一个自动化MySQL配置安装及初始化数据库(初始化包括:设置用户名和密码,导入初始数据库)。 批处理 用来对某对象进行批量处理,即通过批处理可以让相应的软件执行自动化操作。 Mysql免安装版使用步骤 1.配置环境变量 2.创建Mysql配置文件 3.注册Mysql服务 4.启动Mysql服务 5.设置Mysql数据库用户名密码为指定账户密码 6.导入数据库 创建一个.bat文件复制下边的代码执行,更改相应的需求即可 配置环境变量 //set PATH=%PATH%;%MYSQL_HOME%; //set RegV=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment //reg add "%RegV%" /v "MYSQL_HOME" /d %MYSQL_HOME% //reg add "%RegV%" /v "Path" /t REG_EXPAND_SZ /d "%PATH%" /f setx -m MYSQL_HOME "D:\MySql\mysql-5.7.18-win32" setx -m Path "%Path%;%%MYSQL_HOME%%\bin;" 创建Mysql配置文件 sql]