HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how do i insert 'carriage return' in script?
Operating System - HP-UX
1827955
Members
2740
Online
109973
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2004 12:19 PM
08-01-2004 12:19 PM
Sorry this should have been posted here.
I made one script file.
------------here-----------
ftp -n host_ip <<-EOF
user user_id user_pwd
cd /home/test
bin
prompt off
get test.txt
bye
EOF
---------------------------
/usr/bin/sh here
---------------------------
this processed well.
but i want to insert that in '.c source'
------------test.c--------
snprintf(cmd_str, sizeof(cmd_str),"ftp -n host_ip <<-EOF\r\nuser user_id user_pwd\r\nbinary\r\nprompt off\r\ncd /home/test\r\nget test.txt\r\nbye\r\nEOF");
execl("/usr/bin/sh","sh","-c",cmd_str,NULL);
---------------------------
compiled and execute..
printed warnings and failed to copy a file.
?Invalid command
Interactive mode off.
?Invalid command
---------------------------
plz help me..
I made one script file.
------------here-----------
ftp -n host_ip <<-EOF
user user_id user_pwd
cd /home/test
bin
prompt off
get test.txt
bye
EOF
---------------------------
/usr/bin/sh here
---------------------------
this processed well.
but i want to insert that in '.c source'
------------test.c--------
snprintf(cmd_str, sizeof(cmd_str),"ftp -n host_ip <<-EOF\r\nuser user_id user_pwd\r\nbinary\r\nprompt off\r\ncd /home/test\r\nget test.txt\r\nbye\r\nEOF");
execl("/usr/bin/sh","sh","-c",cmd_str,NULL);
---------------------------
compiled and execute..
printed warnings and failed to copy a file.
?Invalid command
Interactive mode off.
?Invalid command
---------------------------
plz help me..
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2004 12:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2004 12:41 PM
08-01-2004 12:41 PM
Re: how do i insert 'carriage return' in script?
Not entirely sure but I would...
1) Drop the \r in the print. Just use \n
2) Chose between
2A) creating a temp file to execute or
2b) opening a pipe to the executable and feed it commands
2c) creating a string simialr to what you do, but tell the shell echo (or print) function to feed lines into the image. A string like 'echo "user id,pwd\nprompt\n..." | ftp -n ip'.
Good luck,
Hein.
1) Drop the \r in the print. Just use \n
2) Chose between
2A) creating a temp file to execute or
2b) opening a pipe to the executable and feed it commands
2c) creating a string simialr to what you do, but tell the shell echo (or print) function to feed lines into the image. A string like 'echo "user id,pwd\nprompt\n..." | ftp -n ip'.
Good luck,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2004 12:44 PM
08-01-2004 12:44 PM
Re: how do i insert 'carriage return' in script?
I got your program to run by making a few modifications:
#include
main ()
{
static char cmd_str[200];
snprintf(cmd_str, sizeof(cmd_str), "ftp -v -n SYSTEM <<-EOF\nuser USER
PASSWORD\nbinary\nprompt off\ncd /home/USER\nget test.txt\nbye\nEOF", NULL);
execl("/usr/bin/sh", "sh", "-c", cmd_str, NULL);
}
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
#include
main ()
{
static char cmd_str[200];
snprintf(cmd_str, sizeof(cmd_str), "ftp -v -n SYSTEM <<-EOF\nuser USER
PASSWORD\nbinary\nprompt off\ncd /home/USER\nget test.txt\nbye\nEOF", NULL);
execl("/usr/bin/sh", "sh", "-c", cmd_str, NULL);
}
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP