sh

Linux bash script for loop

被刻印的时光 ゝ 提交于 2019-12-23 06:11:41
问题 i have 1.txt 2.txt and script.php 1.txt: a b c d 2.txt www rrr ttt yyy i want bash file to do this command in Linux: ./script.php -n a -j www>>n_j.txt ./script.php -n a -j rrr>>n_j.txt ./script.php -n a -j ttt>>n_j.txt ./script.php -n a -j yyy>>n_j.txt ./script.php -n b -j www>>n_j.txt ./script.php -n b -j rrr>>n_j.txt ./script.php -n b -j ttt>>n_j.txt . . i have a bat code working with wondows cmd..i wanna a code like it to work with Linux command line @ECHO OFF FOR /F "tokens=1 delims= " %

Running PhantomJS from PHP with exec()

我的梦境 提交于 2019-12-23 05:29:14
问题 I've got the following script: #!/bin/sh export DISPLAY=:0 phantomjs --version It try to run it from the following PHP script: <?php $result = shell_exec('sh test.sh'); echo $result; ?> This script return the following error: [Thu Jun 19 10:31:31 2014] [error] [client] test.sh: line 3: phantomjs: command not found I tried to run phantomjs -v by hand in a console, and it runs fine. I checked the PATH , and phantomjs is correctly defined and found. The execution environment is a virtual Server

bash script which downloads a file with sftp

百般思念 提交于 2019-12-23 04:19:10
问题 I need to make a sftp connection with a password and download a file. There is an ip restriction so first of all i should make a ssh connection. I wrote a script but it stucks after connecting with ssh. Note: i also tried doing it with an expect script but it also didn't work. #!/usr/local/bin/ ssh test@test1.t.com lftp sftp://test2:123456@test2.com get "file.xls" Edit: You can also see my expect code here. #!/usr/local/bin/expect -f expect -c " spawn ssh test@test1.t.com expect \"test\@test1

AWK Multiple Field Separators and Variables

霸气de小男生 提交于 2019-12-23 03:47:25
问题 I am trying to perform calculations in awk using fields whose numbers are passed in from the shell, as well as the last four fields e.g. I call my shell script like this ./myProgram myFile.txt 1 2 3 4 Then within my shell script I want to use awk to refer to fields in a text file like this, specifically the last four fields. $(NF-3) - $(NF) 0000000022:trevor:736:1,2:3,4 0000000223:john:73:5,6:7,8 0000002224:eliza:54:9,8:7,6 0000022225:paul:22:5,4:3,2 0000222226:chris:0:1,2:3,4 So I can go

Removing first 3 characters of file names in linux

萝らか妹 提交于 2019-12-23 03:34:21
问题 I need a sh script to do remove the first 3 characters of file names, for example: "AB file 1.pdf" "BC file 2.pdf" "DB file 3.pdf" "AD file 4.pdf" ... to: "file 1.pdf" "file 2.pdf" "file 3.pdf" "file 4.pdf" ... I think the script will be like: #!/bin/sh for i in *.pdf; do newName= ???? mv $i $newName done 回答1: Use the cut command: newName=$(echo "$i" | cut -c4-) In bash you can use a Parameter Expansion extension: newName=${i:3} Also, don't forget to quote your variables: mv "$i" "$newName"

How to pass an asterisk to module “sh” in python?

懵懂的女人 提交于 2019-12-23 00:51:11
问题 I'm using the "sh" module in python in order to call external commands on Linux. In my particular case I would like to call the "du" command because it is more efficient than doing such calculations "by hand". Unfortunately the following line does not work: output = sh.du('-sx', '/tmp/*') But this does work: output = sh.du('-sx', '/tmp/') If I pass an asterisk I get the following error message: 'ascii' codec can't encode character u'\u2018' in position 87: ordinal not in range(128) Does

How to pass an asterisk to module “sh” in python?

柔情痞子 提交于 2019-12-23 00:51:01
问题 I'm using the "sh" module in python in order to call external commands on Linux. In my particular case I would like to call the "du" command because it is more efficient than doing such calculations "by hand". Unfortunately the following line does not work: output = sh.du('-sx', '/tmp/*') But this does work: output = sh.du('-sx', '/tmp/') If I pass an asterisk I get the following error message: 'ascii' codec can't encode character u'\u2018' in position 87: ordinal not in range(128) Does

sh.exe is preventing windows cmd move command from working

岁酱吖の 提交于 2019-12-22 11:25:14
问题 I am running an old application called ACSLX . It is trying to call a DOS move command, but because sh.exe is in my path, I am getting an error. sh.exe is part of Git and also RTools , both of which I have installed. As you can see it is simply trying to move a file, but this is failing. How can I prevent this? This is the console output of ACSLX when I try to build the "Spring" example project. ##### Build starting... C:\acslX\ShSysTime.exe Current System Time 15:05:02 "C:\acslX\atrans.exe"

Can I use an existing SSH connection and execute SCP over that tunnel without re-authenticating?

女生的网名这么多〃 提交于 2019-12-22 09:09:19
问题 I'm wondering if I already have an established SSH tunnel and I want to minimize re-authenticating with an ssh server for each task, is there a way to use an existing tunnel to pull a file from the SSH server using SCP on the local machine without re-authenticating? I'm trying to avoid using ssh keys, I'd just like to minimize the amount of times a password needs to be entered for a bash script. ssh -t user@build_server "*creates a build file...*" Once that command is completed there is a