scripting

What does exec ${PERL-perl} -Sx $0 ${1+“$@”} mean in Shell script?

自作多情 提交于 2019-12-13 02:49:27
问题 I'm given a task to convert a shell script which contains Shell script, Perl code to Python. I managed to convert the Perl code to Python. But there is this shell script statement which I didn't understand. #! /usr/bin/sh exec ${PERL-perl} -Sx $0 ${1+"$@"} #! /opt/tools/perl5/bin/perl Some Perl code which I converted to Python What does this 2nd line means? I understood that $0 will be evaluated to the script name. And I'm assuming that ${PERL-perl} will evaluate to whatever Perl interpreter

How do I pass a variable from my local server to a remote server?

一个人想着一个人 提交于 2019-12-13 02:36:54
问题 I am trying to pass a variable from my local server (location1) to a remote server (location2). The purpose of the code is to copy a file from the remote server from a predefined location. In simpler terms, I want to copy files from location2 to location1 using a predefined path where location1 is on the local server and location2 is a remote server. See the code segment: $location1=somewhere/on/local_server $location2=somewhere/on/remote_server sshpass -p "password" ssh username@74.11.11.11

What is “Dim fso, MyFile, FileName, TextLine” in VBA?

微笑、不失礼 提交于 2019-12-13 02:34:43
问题 I received this code from one of those nice people here who are willing to spend their time and energy to share their knowledge with noobs: Sub ReadLinesFromAFileOneAfterAnother () Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, MyFile, FileName, TextLine Set fso = CreateObject("Scripting.FileSystemObject") FileName = "c:\testfile.txt" Set MyFile = fso.OpenTextFile(FileName, ForReading) '' Read from the file Do While MyFile.AtEndOfStream <> True TextLine = MyFile.ReadLine ''

How to start a process on a remote server, disconnect, then later collect output?

不想你离开。 提交于 2019-12-13 02:09:43
问题 I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines). I've considered a couple of ideas, namely:

Powershell: run msiexec with dynamically created parameters

走远了吗. 提交于 2019-12-13 01:44:06
问题 in my powershell script, I need to run msiexec and pass few parameters to initialize it. The problem is, that if a parameter contains space character " ", powershell doesn't execute msiexec correctly. For example the command: msiexec /i .\Setup.msi ConnectionString="Initial Catalog=something;Integrated Security=True;Pooling=False" The parameter ConnectionString contains spaces, and this causes that msiexec is not executed correctly, I get msiexec error code 1639 - Invalid command line

Automatically Convert Prices on a Web Page to A Different Currency

微笑、不失礼 提交于 2019-12-13 01:35:24
问题 I am interested in possible methods of automatically converting the prices given when a web page is loaded from the currency given to a specified currency. Ideally, the conversion would also make use of the current exchange rate to give valid prices. For example, in my specific case, I would like to convert the prices given in Euros (€) on this web site to Sterling (£). I am looking at using a GreaseMonkey script for this conversion, but can anyone suggest other methods? Thanks, MagicAndi.

Can you implement OS X's Finder download progress bars from a shell script?

青春壹個敷衍的年華 提交于 2019-12-13 01:29:35
问题 At first I thought this might be some variation on the extended attributes that can be modified with the xattr command line tool. However, I've staged several tests, and the files don't seem to have any special attributes while in this mode. Is this accessible at all from the command line, or is it only possible from within some cocoa api? 回答1: If you don't mind scripting with swift: #!/usr/bin/env swift import Foundation let path = ProcessInfo.processInfo.environment["HOME"]! + "/Downloads/a

Loading different scripts versions depending on IE version

流过昼夜 提交于 2019-12-13 00:49:59
问题 I have an asp.net mvc 4 web application that must be compatible with IE 7 to IE 10 and then depending on the IE used I have problems with some scripts version (jquery, etc.) so under my root scripts folder I have created a new folder called OlderIE. When IE 7 is used I want the scripts in OlderIE folder to be loaded. And when IE > 7 is used, the I want scripts in Scripts root folder to be loaded. So how to do this? Related to this, is it possible to have installed in my asp.net mvc 4 project

Reading username and password from file

风格不统一 提交于 2019-12-12 21:02:46
问题 I'm looking at a away of reading the username and password of a file and inputing those to either add user or delete user. EG: I have a file named 'userlist' with the following content with this format: user1 pass1 user2 pass2 user3 pass3 What I don't understand completely is how to use BASH script to add these accounts. What I have so far is this: if [[ whoami -ne "root" ]] then exit else echo "wish to add or delete? a/d" read uArg echo "enter file name" read uFile if [ $uArg = "a" -o $uArg

Shell scripts and the md5/md5sum command: need to decide when to use which one

為{幸葍}努か 提交于 2019-12-12 19:07:14
问题 First time poster, here, so go easy on me. :) Pretty sure nobody's yet asked this in researching this question. Short version: How can I tell a shell script to use one command versus the other, depending on which box I run the shell script on? Example: on Box 1, I want to run md5 file.txt . On Box 3, I want to run md5sum file.txt . I'm thining it's an IF command where if the output of md5 is a failure, use md5sum instead. Just don't know how to check and see whether the output of md5 is a