scripting

Test if URL is accessible from web browser i.e. make sure not blocked by Proxy server

只愿长相守 提交于 2020-01-10 01:45:08
问题 I am serving my website from mywebsite.com. I host images on flickr so all images are loaded in the user's browser via get requests to flickr. Many of my websites users access mywebsite.com from corporate networks, which block access to flickr.com. This means users get very annoying blank placeholders instead of the images. I get the same problem with the Facebook like button. This makes my site look very unattractive to such users. Is there a way I can run a client side script which will

How to pass arguments from wrapper shell script to Java application?

社会主义新天地 提交于 2020-01-09 19:19:08
问题 I want to run Java programs I am creating at on the command line (linux and mac). I don't want to type "java" and arguments all the time, so I am thinking about creating wrapper scripts. What's the best way to do this so that they work everywhere? I want to be able to pass arguments, too. I was thinking of using "shift" to do this (removing first argument). Is there a better way to do this without using scripts at all? Perhaps make an executable that doesn't require invocation through the

Praat scripting: creating a text file

泄露秘密 提交于 2020-01-09 11:48:29
问题 just working with Praat at the moment, and I'm trying to write a script to do the following with a collection of 3 Sound (narrative) files. I've managed as far as c), the scripting part is relatively easy. What I don't get is how to write it to a text file with those columns. Any help would be great! a) create a program that extracts all intervals on the phone tier of each of Narratives 1–3 which represent vowels whose label is a single letter, keeping times. I need each resulting Sound to

Do I have a way to check the existence of a directory in Ant (not a file)?

可紊 提交于 2020-01-09 06:04:20
问题 How do I check for the existence of a folder using Ant? We can check the existence of a file, but can we do the same for a folder as well? 回答1: You use the available task with type set to "dir". For example: <available file="${dir}" type="dir"/> The standard way to do conditional processing is with the condition task. In the example below, running doFoo will echo a message if the directory exists, whereas running doBar will echo a message unless the directory exists. The dir.check target is

Difference between launching a script with ./script.sh and . ./script.sh

社会主义新天地 提交于 2020-01-09 05:19:45
问题 Please tell me what is the difference in bash shell between launching a script with ./script.sh and . ./script.sh ? 回答1: As klausbyskov says, the first form requries that the file have its executable permission bit set. But more importantly, the first form executes the script in a separate process (distinct from, independent of, and unable to make changes in the shell that launched it). The second form causes the initial shell to directly run the commands from the file (as if you had typed

Meaning of $? (dollar question mark) in shell scripts

烈酒焚心 提交于 2020-01-08 17:25:30
问题 What does echo $? mean in shell programming? 回答1: This is the exit status of the last executed command. For example the command true always returns a status of 0 and false always returns a status of 1 : true echo $? # echoes 0 false echo $? # echoes 1 From the manual: (acessible by calling man bash in your shell) $? Expands to the exit status of the most recently executed foreground pipeline. By convention an exit status of 0 means success, and non-zero return status means failure. Learn more

Add a prefix string to beginning of each line

帅比萌擦擦* 提交于 2020-01-08 11:23:21
问题 I have a file as below: line1 line2 line3 And I want to get: prefixline1 prefixline2 prefixline3 I could write a Ruby script, but it is better if I do not need to. prefix will contain / . It is a path, /opt/workdir/ for example. 回答1: # If you want to edit the file in-place sed -i -e 's/^/prefix/' file # If you want to create a new file sed -e 's/^/prefix/' file > file.new If prefix contains / , you can use any other character not in prefix , or escape the / , so the sed command becomes 's#^#

Add a prefix string to beginning of each line

对着背影说爱祢 提交于 2020-01-08 11:22:37
问题 I have a file as below: line1 line2 line3 And I want to get: prefixline1 prefixline2 prefixline3 I could write a Ruby script, but it is better if I do not need to. prefix will contain / . It is a path, /opt/workdir/ for example. 回答1: # If you want to edit the file in-place sed -i -e 's/^/prefix/' file # If you want to create a new file sed -e 's/^/prefix/' file > file.new If prefix contains / , you can use any other character not in prefix , or escape the / , so the sed command becomes 's#^#

Copy or move files to another directory based on partial names in a text file

萝らか妹 提交于 2020-01-07 08:28:15
问题 I want to copy some files from directory A to directory B on basis of partial filenames which are in a text file. I tried the command below, but it's not working for fn in $(cat filename.txt); do find . -type -f -name '$fn*' \ -exec rsync -aR '{}' /tmp/test2 \; File names are in format abcd-1234-opi.txt , rety-4567-yuui.txt . I have to grep numbers from file names and then copy those files to another folder, I have numbers in a text file. Can anybody guide me? 回答1: If I understand your

Delete a line containing exact pattern in linux [closed]

蹲街弑〆低调 提交于 2020-01-07 07:56:20
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 days ago . I want to delete the lines in test_bash.sh containing the below exact pattern: export PATH=$PATH:$JAVA_HOME/bin test_bash.sh #JAVA PATH export JAVA_HOME=/data/jdk1.8.0_111 export PATH=$PATH:$JAVA_HOME/bin export JAVA_OPTS='Xms2048m -Xmx8192m' #HADOOP PATH export HADOOP_HOME=/data/hadoop-2.8.5 export