WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Problems trying to write a text file to a network location  (Read 7216 times)

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Problems trying to write a text file to a network location
« 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

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Problems trying to write a text file to a network location
« Reply #1 on: December 12, 2012, 10:49:28 PM »
Did you double check your paths?

Which ssh client are you using?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ananix

  • Full Member
  • ***
  • Posts: 174
Re: Problems trying to write a text file to a network location
« Reply #2 on: December 13, 2012, 01:40:41 PM »
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?

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Re: Problems trying to write a text file to a network location
« Reply #3 on: December 13, 2012, 02:05:11 PM »
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
Quote
#!/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:
Quote
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

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Problems trying to write a text file to a network location
« Reply #4 on: December 13, 2012, 02:21:22 PM »
You state that you are trying to scp a file, but your script does a cp.
That is scp syntax, not cp.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Problems trying to write a text file to a network location
« Reply #5 on: December 13, 2012, 02:40:46 PM »
...while in OP it was indeed scp...

A top level dir named "/company" would be most unorthodox in the least...
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Re: Problems trying to write a text file to a network location
« Reply #6 on: December 13, 2012, 02:50:39 PM »
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:
Quote
#!/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:
Quote
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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11590
Re: Problems trying to write a text file to a network location
« Reply #7 on: December 13, 2012, 02:54:19 PM »
Hi ambaum01
scp is available from the  openssh.tcz  extension.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Problems trying to write a text file to a network location
« Reply #8 on: December 13, 2012, 03:07:37 PM »
Did you install the openssh or dropbear extension?

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Re: Problems trying to write a text file to a network location
« Reply #9 on: December 13, 2012, 03:11:14 PM »
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:
Quote
#!/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?

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Problems trying to write a text file to a network location
« Reply #10 on: December 13, 2012, 03:29:36 PM »
I would recommend setting up key authentication for your scp.

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Re: Problems trying to write a text file to a network location
« Reply #11 on: December 13, 2012, 04:24:28 PM »
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?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11590
Re: Problems trying to write a text file to a network location
« Reply #12 on: December 13, 2012, 08:44:34 PM »
Hi ambaum01
Just a guess on my part::
Code: [Select]
cd /usr/local/etc/ssh/
cp sshd_config.example sshd_config
editor sshd_config
Change the line that reads
Code: [Select]
#ChallengeResponseAuthentication yesto
Code: [Select]
ChallengeResponseAuthentication noThen run:
Code: [Select]
/usr/local/etc/init.d/openssh restartSee if it still prompts you for a password.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Problems trying to write a text file to a network location
« Reply #13 on: December 13, 2012, 09:52:55 PM »
Key authentication would be as recommendable under ubuntu, regardless of the toolkit vs. kitchen sink difference.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ambaum01

  • Newbie
  • *
  • Posts: 17
Re: Problems trying to write a text file to a network location
« Reply #14 on: December 13, 2012, 10:05:07 PM »
Hi ambaum01
Just a guess on my part::
Code: [Select]
cd /usr/local/etc/ssh/
cp sshd_config.example sshd_config
editor sshd_config
Change the line that reads
Code: [Select]
#ChallengeResponseAuthentication yesto
Code: [Select]
ChallengeResponseAuthentication noThen run:
Code: [Select]
/usr/local/etc/init.d/openssh restartSee if it still prompts you for a password.

Thank you for your help.  I'll give this a go and report back.