I am writing a simple Perl script that is attempting to automate checking in files via SVN. I am not using any given SVN clients within Perl and for the sake of simplicity am just using command line arguments.
Whenever I run the svn checkout command seen below, I am getting this error:
sh[2]: svn+ssh://my/repo/url/project/trunk: not found.
Here is the command and the variable declarations.
$svn_root = "svn+ssh://my/repo/url/project/trunk";
$user = `whoami`;
`svn checkout -q --username $user $svn_root workingCopyName`;
I should note that I am connecting to the repository via SSH and have edited my config file (and included -q just in case). I will also note that running this command outside of the script works perfectly fine, for the same exact URL, and without the -q argument.
Thanks for your help. Please let me know if I need to clear anything up.
Note that the error is coming from the shell, not svn.
You are executing
svn checkout -q --username user
svn+ssh://my/repo/url/project/trunk workingCopyName
when you mean to execute
svn checkout -q --username user svn+ssh://my/repo/url/project/trunk workingCopyName
because $user contains a newline. Replace
my $user = `whoami`;
with
chomp( my $user = `whoami` );
Related
I'm running a Python script on my local computer using the Shortcuts app from my phone (this works perfectly well and returns data to my phone). I also want the script to display a web browser on the local computer. The code for this is simple:
import webbrowser
import sys
print("This print statement is shown on my phone")
webbrowser.get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe%s').open(str(sys.argv)) # works locally but not over ssh
print("This print statement is also shown on my phone")
But to make SSH display I'm confident that I would need the ssh -X or -Y argument which cannot be passed into the shortcuts app.
I can see two solutions which might work but I haven't been able to find
There is an equivalent argument to -X or -Y which can be passed in the main body of text for the ssh command
There is a way to pass arguments to the shortcut app
Any thoughts would be greatly appreciated!
not sure if i understand you correctly.
But, if you ask how to include parameters in your ssh that are attributed to the script you call. I made an example triggering a bash script through ssh, supplied with params.
# some variables
X="True"
Y="False"
Z="True"
# bash script
# echo supplied parameters
echo "$1"
echo "$2"
echo "$3"
# ssh command
sshpass -p 'pswd' ssh user#host "bash -s" < /home/user/sc.sh "$X $Y $Z"
I having a bunch of Linux Servers on which i need to run few commands to get the host file entry of backup servers. I am using planning to make power shell script using plink to achieve this . It logs me in the server but the commands does not execute. Below is Powershell console
$switch = "172.20.19.50"
$commands = "c:\scripts\cmd.txt"
$username = root
$pw = Read-Host -Prompt "Enter password" -AsSecureString
plink -ssh $switch -l $username -pw $pw -m $commands
output
bash: Support: command not found
bash: Maintenance: command not found
my c:\scripts\cmd.txt contains following two commands :
Support
Maintenance
is there anything in command i am missing here ? Also if anyone could suggest a better way to get the output from linux servers remotely will be great help . I just need to query few commands to get the output
In 99.999% of all cases, if a computer tells you it cannot find something, the reason is, that that something is, in fact, not there. So, are you 100% sure that those commands exist on your server?
In the remaining cases, the reason is, that the thing is there, but not in the right place. Are you 100% sure that those commands are in root's $PATH?
I made a script wich does the same (connect to UNIX machine and execute command using Powershell) and I had to make this:
echo y | & $Plinkpath -P 22 -v $User#$server -pw $passw "$commands $($target)"
Where $commands are:
/usr/local/bin/sudo /usr/sbin/userdel
Because sudo and userdel was not always in mi $PATH (as said Jörg W Mittag) i've to use the full path to the command.
Hope this works for you!
I've been seeing '-u' used a lot in command line and I'd like to know what it does. For example, when it's used in:
git push -u origin master
or
mysql -u root
Sometimes means user, but each program sets whatever it want.
I want to install Anaconda through EasyBuild. EasyBuild is a software to manage software installation on clusters. Anaconda can be installed with sh Anaconda.sh.
However, after running I have to accept the License agreement and give the installation location on the command line by entering <Enter>, yes <Enter>, path/where/to/install/ <Enter>.
Because this has to be installed automatically I want to do the accepting of terms and giving the install location in one line. I tried to do it like this:
sh Anaconda.sh < <(echo) >/dev/null < <(echo yes) >/dev/null \
< <(echo /apps/software/Anaconda/1.8.0-Linux-x86_64/) > test.txt
From the test.txt I can read that the first echo works as <Enter>, but I can't figure out how to accept the License agreement, as it sees it now as not sending yes:
Do you approve the license terms? [yes|no]
[no] >>> The license agreement wasn't approved, aborting installation.
How can I send the yes correctly to the script input?
Edit: Sorry, I missed the part about having to enter more then one thing. You can take a look at writing expect scripts. thegeekstuff.com/2010/10/expect-examples. You may need to install it however.
You could try piping with the following command: yes yes | sh Anaconda.sh. Read the man pages for more information man yes.
Expect is a great way to go and probably the most error proof way. If you know all the questions I think you could do this by just writing a file with the answers in the correct order, one per line and piping it in.
That install script is huge so as long as you can verify you know all the questions you could give this a try.
In my simple tests it works.
I have a test script that looks like this:
#!/bin/sh
echo -n "Do you accept "
read ANS
echo $ANS
echo -n "Install path: "
read ANS
echo $ANS
and an answers file that looks like this:
Y
/usr
Running it like so works... perhaps it will work for your monster install file as well.
cat answers | ./test.sh
Do you accept Y
Install path: /usr
If that doesn't work then the script is likely flushing and you will have to use expect or pexpect.
Good luck!
Actually, I downloaded and looked at the anaconda install script. Looks like it takes command line arguments.
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -h
usage: Anaconda-2.2.0-Linux-x86_64.sh [options]
Installs Anaconda 2.2.0
-b run install in batch mode (without manual intervention),
it is expected the license terms are agreed upon
-f no error if install prefix already exists
-h print this help message and exit
-p PREFIX install prefix, defaults to /home/cody.stevens/anaconda
Use the -b and -p options...
so use it like so:
/bin/bash Anaconda-2.2.0-Linux-x86_64.sh -b -p /usr
Also of note.. that script explicitly says not to run with '.' or 'sh' but 'bash' so they must have some dependency on a feature of bash.
--
Cody
Will the parameter --non-interactive work for import? Example:
svn import -m "SVN Project created" --username $NAME --password $PASS "$tempProjectPath" "$SVN"
Result line:
svn import -m "SVN Project created" --username $NAME --password $PASS --non-interactive "$tempProjectPath" "$SVN"
I use this line in a Perl script to automatically import a folder into a repository. That's why the comment and password dialogs are inappropriate for me.
I use FreeBSD OS.
I tried to check it manually by importing an empty dir to repository. Example:
svn import -m "Manual import Test 1" --username Maxus --password 1111 --non-interactive "/tmp/reti" "svn://192.168.0.57"
But nothing happened.
Maybe, you have another idea - how to execute shell command svn import in Perl without dialogs for commit comments or passwords? Or how I can ignore/complete those dialogs from a shell command?
The URL for a repo served with svnserve has three parts:
svn://
server/
path/to/repo
As Lazy Badger pointed out in the comments (and as you yourself discovered by running on the command line), you are missing the path/to/repo part. svnserve will not know which repo you are trying to access unless you give it a path.
If you used the --root=dir option when you started svnserve, the path you give in the URL will be interpreted relative to dir.
Now, based on your last comment, you already know that the command works on the command line when you put a path in the URL. Use that URL in your Perl command and it should work.