Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: ambaum01 on December 12, 2012, 10:38:22 PM
-
I am very new to tiny core and am having trouble recreating the results of an existing script running on Ubuntu. On the Ubuntu machine, I am writing the file using this code:
eval spawn scp /home/kamal/log.txt user@SERVER:/company/manufacturing/dir
This code works fine on Ubuntu, but is giving me problems with tiny core. I keep getting the error that the directory is invalid. Are there additional steps I need to take?
Thanks for any help, as I really do appreciate it. This is not only my first adventure with tiny core, but with linux in general.
-Aaron
-
Did you double check your paths?
Which ssh client are you using?
-
Think you need to be more precise
are you running the script in tcl or just that one line?
Im guessing the script.
Is that the precise error?
Im guessing not, im guessing it says "No such file or directory"
what is giving you that error?
Im guessing bash
so when you run your script you get this
-bash: /usr/sbin/expect: No such file or directory
what scripting language are you using?
The first line of your ubuntu script should state the interpreter path with a #!
Maybe it points to "expect"
In that case you need to install inspect.
Maybe im all wrong and you actualy wrote a precise description.
Can i ask what you are trying to achive?
-
Did you double check your paths?
Which ssh client are you using?
The path is good (as it works with the Ubuntu machine), but I do not know what ssh client I am using. It just seems to work on the Ubuntu machine fine.
Think you need to be more precise
are you running the script in tcl or just that one line?
Im guessing the script.
Is that the precise error?
Im guessing not, im guessing it says "No such file or directory"
what is giving you that error?
Im guessing bash
so when you run your script you get this
-bash: /usr/sbin/expect: No such file or directory
what scripting language are you using?
The first line of your ubuntu script should state the interpreter path with a #!
Maybe it points to "expect"
In that case you need to install inspect.
Maybe im all wrong and you actualy wrote a precise description.
Can i ask what you are trying to achive?
I am running the following script
#!/usr/bin/expect -f
set server SERVERNAME
eval spawn cp /home/kamal/log.txt username@SERVERNAME:/company/dir
match_max 100000
expect "username@servername's password: $"
send -- "password\n"
expect "$ $"
The exact error I receive:
cp: can't create 'username@SERVERNAME:/company/dir': Path does not exist
Nothing that says bash, it simply prints the above line.
I am assuming that the language is expect? I have installed the expect extension in tcl. All I really need to do is take a file called log.txt that is created on this tcl machine and place it in a specific directory on our server. The problem with this is that our old setup works fine and was developed by a different engineer who no longer works for the company. now I am stuck with fixing this to work with a machine running tcl. Hopefully I can figure this out. Thanks!
-Aaron
-
You state that you are trying to scp a file, but your script does a cp.
That is scp syntax, not cp.
-
...while in OP it was indeed scp...
A top level dir named "/company" would be most unorthodox in the least...
-
You state that you are trying to scp a file, but your script does a cp.
That is scp syntax, not cp.
Is the scp command supported in tcl? When I tried running this script with scp, it said scp not found, so I tried changing it to cp. I also removed 'eval spawn' because it was having trouble with those. This is all due to my lack of knowledge, just trying to brute force through this to get a working solution.
So, I've changed the code back to:
#!/usr/bin/expect -f
set server SERVERNAME
eval spawn scp /home/kamal/log.txt username@SERVERNAME:/company/dir
match_max 100000
expect "username@servername's password: $"
send -- "password\n"
expect "$ $"
and it gives me the error:
scpfiles.sh: eval: line 1: spawn: not found
couldn't read file "username@servername's password: $": no such file or directory
scpfiles.sh: line 12: send: not found
couldn't read file "$ $": no such file or directory
-
Hi ambaum01
scp is available from the openssh.tcz extension.
-
Did you install the openssh or dropbear extension?
-
Hi ambaum01
scp is available from the openssh.tcz extension.
Wonderful! So now I have written log.txt to the required directory. Thank you so much.
I am now having a problem with the password entry. It seems as if the expect statement is not working. I already have the expect extension loaded, so i know that is not the issue. After the scp command, it immediately prompts me for the password, which should be taken care of by the expect command, but obviously it is not. Any ideas? Thanks so much!
Current code:
#!/usr/bin/expect -f
set server SERVERNAME
scp /home/kamal/log.txt username@SERVERNAME:/company/dir
match_max 100000
expect "username@servername's password: $"
send -- "password\n"
expect "$ $"
Did you install the openssh or dropbear extension?
I have not installed these extensions, but the file is being written now. Do I need them?
-
I would recommend setting up key authentication for your scp.
-
I would recommend setting up key authentication for your scp.
After quickly looking this up, I'm willing to bet it is way over my head. This scpfiles.sh script runs fine when it comes to network auth on the Ubuntu machine. Is there any reason why the same wouldn't work with tcl?
-
Hi ambaum01
Just a guess on my part::
cd /usr/local/etc/ssh/
cp sshd_config.example sshd_config
editor sshd_config
Change the line that reads
#ChallengeResponseAuthentication yes
to
ChallengeResponseAuthentication no
Then run:
/usr/local/etc/init.d/openssh restart
See if it still prompts you for a password.
-
Key authentication would be as recommendable under ubuntu, regardless of the toolkit vs. kitchen sink difference.
-
Hi ambaum01
Just a guess on my part::
cd /usr/local/etc/ssh/
cp sshd_config.example sshd_config
editor sshd_config
Change the line that reads
#ChallengeResponseAuthentication yes
to
ChallengeResponseAuthentication no
Then run:
/usr/local/etc/init.d/openssh restart
See if it still prompts you for a password.
Thank you for your help. I'll give this a go and report back.
-
Hi ambaum01
Just a guess on my part::
cd /usr/local/etc/ssh/
cp sshd_config.example sshd_config
editor sshd_config
Change the line that reads
#ChallengeResponseAuthentication yes
to
ChallengeResponseAuthentication no
Then run:
/usr/local/etc/init.d/openssh restart
See if it still prompts you for a password.
No luck, it is still prompting me for a password as it was before.
-
Hi ambaum01
As I said, it was just a guess.
-
I appreciate it just the same. this is a pretty frustrating problem. If I could just get past this hurdle I think I could make this thing work.
-
Instead of trying to circumvent ssh security, you could as well consider to look into nc and netcat the file content.
-
HI tinypoodle
I don't think he's trying to circumvent ssh security. He's trying to get the script to submit the password.
-
HI tinypoodle
I don't think he's trying to circumvent ssh security. He's trying to get the script to submit the password.
This exactly.
-
Hi ambaum01
I've never worked with expect myself, but suspect the problem may be in the script. For example:
expect "username@servername's password: $"
This is what expect is looking for from ssh. It's very specific, so if your syntax for the response is not exactly right, it
will fail. I recommend Googling linux expect scp example to find a better starting point for a more robust script.
Google will return a lot of examples related to what you want with that search phrase.
-
HI tinypoodle
I don't think he's trying to circumvent ssh security. He's trying to get the script to submit the password.
Your statement leaves me puzzled... :-\
Perhaps you mean to disagree on semantics while agreeing in essence?
-
Hi tinypoodle
If you consider a script circumventing security, then yes, I disagree on semantics while agreeing in essence.
-
Hi ambaum01,
There is an expect related thread here: http://forum.tinycorelinux.net/index.php/topic,14493.0.html that relates to sending an ssh password using expect. I have a script similar similar to the one shown there that puts or gets a file using scp and using expect to provide the password.
In my case, probably due to some oddity in my system (and my systems -do- have the occasional oddity), these things only work as root (sudo ... ), but they do work.
Of course there are security concerns with embedding passwords in scripts...
-
Thanks for the suggestions. I will do some more research on this forum and elsewhere to get this solved. I've always wanted a reason to become familiar with Linux, and as frustrating as some of this has been, I have been learning a great deal. I greatly appreciate everyone's advice thus far.
-
I finally resolved this issue using ssh. It turns out it was much easier to implement than I initially thought. I've run into a different issue, but I will post it in another thread. Thanks again.