scripting

Unable to source a simple bash script

早过忘川 提交于 2019-12-23 04:35:41
问题 I understand similar questions to this been asked in SO multiple times. However, I couldn't find any usual suspects here. #!/bin/bash myvar="test" if [ "$myvar" == "test" ] then echo "Test mode" fi Spent quite some time on it. Can anyone advice what am I missing? I am able to execute the script, but couldn't source the same. error while source bash: test.sh: line 7: syntax error: unexpected end of file $ which bash /bin/bash $ bash --version 3.2.57(1) I am able to get the same working on my

Awk Search file for string

最后都变了- 提交于 2019-12-23 04:34:32
问题 I have implimented a function that searches a column in a file for a string and it works well. What I would like to know how do I modify it to search all the columns fr a string? awk -v s=$1 -v c=$2 '$c ~ s { print $0 }' $3 Thanks 回答1: If "all the columns" means "the entire file" then: grep $string $file 回答2: Here is an example of one way to modify your current script to search for two different strings in two different columns. You can extend it to work for as many as you wish, however for

Awk Search file for string

不问归期 提交于 2019-12-23 04:34:05
问题 I have implimented a function that searches a column in a file for a string and it works well. What I would like to know how do I modify it to search all the columns fr a string? awk -v s=$1 -v c=$2 '$c ~ s { print $0 }' $3 Thanks 回答1: If "all the columns" means "the entire file" then: grep $string $file 回答2: Here is an example of one way to modify your current script to search for two different strings in two different columns. You can extend it to work for as many as you wish, however for

Batch upload of Blobs to Google App Engine

别等时光非礼了梦想. 提交于 2019-12-23 04:29:51
问题 I'm currently migrating a site to Google App Engine. Previously, all the images and static resources (100s of MBs of the stuff) was just part of the deployment. Now, it's clear, I should use Blob Storage for this in GAE (otherwise updating the app will be mega-painful!). I need to batch upload these images from my disk to GAE and suspect I need some kind of script to do this. Any ideas or suggestions of the best approach? 回答1: The current bulkloader doesn't support this, but it's possible to

Bash script to bring up and down an interface on loop

被刻印的时光 ゝ 提交于 2019-12-23 03:57:35
问题 I use Ubuntu server as NAT router. WAN interface is eth1 and LAN interface is eth0 . I use ucarp virtual ip on LAN side for failover. I am writing a script which will bring down LAN interface eth0 if WAN link or default gateway goes down (If LAN interface goes down, then ucarp can release the NAT gateway ip to another router on the network). Also if the WAN ip gets pinged then LAN interface should come up and should remain up until WAN ip can be pinged. Bash Script: #!/bin/bash t1=$(ifconfig

Get a collection of items in document library/list

六月ゝ 毕业季﹏ 提交于 2019-12-23 03:48:13
问题 I'm new to Powershell. What I'm trying to do is get a list of all the documents in a document library. I have an absolute URL of the document library I want to process, for example. Essentially what I want is a reference to the document library so I can send some CAML queries to it. http://sharepoint2013/sites/superdupersite/shared%20documents Add-PSSnapin Microsoft.SharePoint.Powershell $items = Get-SPList "http://sharepoint2013/sites/superdupersite/shared%20documents" foreach ($item in

How do i compare if my variable holds a newline character in shell Script

為{幸葍}努か 提交于 2019-12-23 03:40:08
问题 I have a script in which I have a line which does put the third line fetched in my variable like this: variable=`sed -n '3 p' /home/nmsadm/abc.txt` So variable holds this value Which is in third line of abc.txt. In my case it will be a one word line or an empty/blank line. How can I compare the variable in a shell script to know if it's an empty/blank line? echo $variable fetched me an empty line. What is the comparison i need to here so that I am assured it's an empty line? Something like

access the title of a window using vbscript

一个人想着一个人 提交于 2019-12-23 03:35:16
问题 I'm trying to get the title of a window using VbScript. Is there any way to achieve it? like the way we do it in C# using System.Diagnostics; Process[] processlist = Process.GetProcesses(); foreach (Process process in processlist) { if (!String.IsNullOrEmpty(process.MainWindowTitle)) { Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle); } } 回答1: Dim Tasks Tasks = Split(WScript.CreateObject("WScript.Shell").Exec("tasklist /v

How to issue “module load” in a shell or Perl script (i.e., non-interactively)

梦想的初衷 提交于 2019-12-23 03:35:07
问题 I can use the "module load xyz" command interactively, but when run from a script, it says it can't find the "module" command. Is there any way of loading modules in a script? 回答1: Start your bash script like this: #!/bin/bash -l Note that modules loaded after this with module load xyz will only be available from inside the script file. 回答2: Try source /etc/profile If that doesn't work, you most likely have a problem with aliases. You may need shopt -s expand_aliases in your script. 回答3: If

Best scripting language for cross compiling to ARM

戏子无情 提交于 2019-12-23 03:16:15
问题 I am looking for the "best" scripting language interpreter for cross compiling to an ARM processor. Here are the requirements for "best": Its small. Ideally, I'd like to be able to decide which parts of the language and "standard" libraries that are supported. (For instance: file system, nah don't want that. Floating point math, nope don't want that either.) Its easy. Ideally, I'd like some documentation/tutorial/examples on how to do the cross-compile. The goal: I'm writing a small, simple