LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2003, 04:27 PM   #1
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
expect


hey, i am trying to get the username from the system in expect

but the $ is a special character reserved for expect variables. so going

set username "[exec echo $USER]"

of course gives me errors. does anyone know the correct way to do this?
 
Old 07-26-2003, 12:27 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Rather than using $user why not use the "whoami" command.
set username "[exec whoami]"
 
Old 07-29-2003, 05:24 AM   #3
coolest
LQ Newbie
 
Registered: Jul 2003
Distribution: RedHat, FreeBSD
Posts: 20

Rep: Reputation: 0
hi Ihave a problem in my expect script

#!/usr/local/bin/expect
set User "updates"
set Password "updates"
set Prompt "ftp>"
set Host "ftp.freedomain.com"
set Yes "prompt"
set Local "/home/ryan/parsedlogs/"
#set Yehey "mput yehey*"
################################################# Connect to FTP
spawn "/home/ryan/parsedlogs"
spawn ftp $Host
################################################# Username
expect "Name (ftp.freedomain.com:ryan):"
send "$User\n"
################################################# Password
expect "Password:"
send "$Password\n"
################################################# Enter Command Option of FTP
#expect "$Prompt"
#send "passive\n"
expect "$Prompt"
send "$Yes\n"
expect "$Prompt"
send "hash\n"
################################################# Upload yeheylogs files
expect "$Prompt\n"
send "mput $Local*.*\r"
expect "$Prompt"
send "ls -al\n"
expect "$Prompt\n"
send "bye\n"

when i run this script it says
spawn /home/ryan/parsedlogs
couldn't execute "/home/ryan/parsedlogs": permission denied
while executing
"spawn "/home/ryan/parsedlogs""
(file "/home/ryan/scripts/ftptest.exp" line 10)
 
Old 07-29-2003, 10:24 PM   #4
x2000koh
Member
 
Registered: Jul 2002
Location: singapore
Distribution: red had 7.2
Posts: 109

Rep: Reputation: 15
sk8guitar,
You can use (id -u) try to look at man id which can return you the user.

at your comand type id, you see your id, uid gid and etc.

try to modify it at your own preference.

hope it help

x2000koh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use expect TomCruise2002 Linux - General 2 04-09-2017 09:00 AM
Expect Script coolest Programming 7 02-16-2009 04:59 PM
Expect how to? e-freak Programming 2 09-24-2005 05:49 AM
help with expect neyoung Programming 3 02-09-2004 10:41 PM
Using Expect for Linux rkeng Linux - General 2 08-01-2003 10:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration